[Resolved] Previous, Next links on Single Product Page – NOT within category

Home Forums Support Previous, Next links on Single Product Page – NOT within category

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1356194
    Simon

    Hi (Tom suggested I started a new topic for this.)

    I want to insert Previous product and Next product links on Single Product Page, but I want to link to the next and previous product alphabetically for the whole product list, and NOT just within the same category

    I’ve adapted the suggested Bloomer code, as below, and it works well for the next and previous within a category. (I’ve made it show the product %title rather than ‘Previous’ and ‘Next’.)

    I have tried FALSE, and removing 'product_cat', to get the whole list, but with no success. I also tried adding var_dump($previous); before echo $previous; as you have suggested. None has worked so far.

    The priority is for it to deliver an alphabetical sequence (not the product upload sequence) for all products.

    Any help gratefully received! Thank you.

    add_action( 'woocommerce_after_single_product', 'bbloomer_prev_next_product' );
     
    function bbloomer_prev_next_product(){
     
    echo '<div class="prev_next_buttons">';
     
       // 'product_cat' will make sure to return next/prev from current category
            $previous = next_post_link('%link', '&larr; %title', TRUE, ' ', 'product_cat');
     		$next = previous_post_link('%link', '%title &rarr;', TRUE, ' ', 'product_cat');
     
       echo $previous;
       echo $next;
        
    echo '</div>';
    }
    #1356429
    David
    Staff
    Customer Support

    Hi there,

    Woo products don’t behave in the way the regular post types do. Even Business Bloomer resorted to using a plugin for their client as seen in step 3 of their article:

    https://www.businessbloomer.com/woocommerce-add-nextprevious-single-product-page/

    Unfortunately you would need to find a plugin specific to your needs or have it custom developed. All i can say is Woo is a pain, and we failed miserably trying to achieve product ordering in the Imprint sites single product navigation:

    https://generatepress.com/site-library/#imprint

    #1357561
    Simon

    David – thank you. It’s good just to know that I’m not being dim, and that this is seriously difficult or impossible! I did try the Post Type Order plugin, but I’ll try again, and get back if something works.

    #1357668
    David
    Staff
    Customer Support

    I hope you have better luck than i did 🙂
    Let us know how you get on.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.