Last active
December 2, 2023 18:33
-
-
Save softiconic/e67bd602f90466fe47c310e16b427446 to your computer and use it in GitHub Desktop.
WooCommerce single product - navigate to the next or previous product.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//add_action( 'woocommerce_before_single_product', 'add_custom_text_before_product_title' ); | |
add_shortcode( 'scnextprev', 'productnextprev_shortcode' ); | |
function productnextprev_shortcode(){ | |
echo '<div class="prev_next_buttons">'; | |
// 'product_cat' will make sure to return next/prev from current category | |
$previous = next_post_link('%link', '← %title', TRUE, ' ', 'product_cat'); | |
$next = previous_post_link('%link', '%title →', TRUE, ' ', 'product_cat'); | |
echo $previous; | |
echo $next; | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment