Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1128865

    Hi,
    I have Portfolio Items in two categories; interior and exterior.
    The Next/Previous tabs seem to cross the categories; meaning that visitors navigate to a different category on this link:
    https://orangerieduras.fr/portfolio-item/orangerie-staircase/
    Can this function be limited to the same category, so that ‘Next’ loops back to the first Portfolio Item in the category?
    Thanks,
    Simon

    • This topic was modified 5 years, 4 months ago by friendlier.
    #1128910

    OK – I found the fix for this, and it took some digging so I’m leaving this post up with the solution, which works (so please close the ticket)!

    /* make previous-next buttons stay within the relevant portfolio category (multiple portfolios) */
    add_filter( 'avia_post_nav_entries', 'enfold_customization_postnav', 10, 2);
    function enfold_customization_postnav($entries, $settings)
    {
    if($settings['type'] == 'portfolio')
    {
    $settings['same_category'] = true;
    $entries['prev'] = get_next_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']);
    $entries['next'] = get_previous_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']);
    }
    return $entries;
    }
    • This reply was modified 5 years, 4 months ago by Mike. Reason: put the code in a code block so it can be copied without curly quotes
    #1129152

    Hi,
    Thank you for sharing your solution, I’m certain others will find this helpful.
    We will close this now, as you asked. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Next/Previous working across categories/ how to restrict to same category’ is closed to new replies.