最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

woocommerce offtopic - show shop instead of 404 page for missing products

matteradmin8PV0评论

How should I show the shop instead of a 404 page when a product is missing? Currently users get a 404 page which makes them loose interest.

I use woocommerce with wordpress on a server with nginx.

How should I show the shop instead of a 404 page when a product is missing? Currently users get a 404 page which makes them loose interest.

I use woocommerce with wordpress on a server with nginx.

Share Improve this question asked May 2, 2018 at 5:42 Ro LRo L 991 gold badge1 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

// Missing product redirect to product category add_filter( 'rewrite_rules_array', function( $rules ) { $new_rules = array( 'shop/([^/]*?)/page/([0-9]{1,})/?$' => 'index.php?product_cat=$matches[1]&paged=$matches[2]', 'shop/([^/]*?)/?$' => 'index.php?product_cat=$matches[1]', ); return $new_rules + $rules; } );

Post a comment

comment list (0)

  1. No comments so far