Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // pokud je v kategorii jediný produkt, přesměrujeme rovnou na jeho detail
- function presmerovani_na_jediny_produkt() {
- global $wp_query;
- if ( is_product_category() && 1 === $wp_query->found_posts ) {
- $product = wc_get_product( $wp_query->post );
- if ( $product && $product->is_visible() ) {
- wp_safe_redirect( get_permalink( $product->id ), 302 );
- exit;
- }
- }
- }
- add_action( 'template_redirect', 'presmerovani_na_jediny_produkt' );
Add Comment
Please, Sign In to add comment