• Hello guys!

    So I have a page structure like below:

    • Parent
    • Page A – Cat 1
    • Page B – Cat 1
    • Page C – Cat 2
    • Page D – Cat 1
    • etc…

    I’m looking for a way to insert “next/prev” links on pages that would work with category groups with no luck so far.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello!

    I believe the solution to what you are trying to accomplish is in the link below.

    https://codex.wordpress.org/Next_and_Previous_Links

    Let me know if this helps you implement this within your website!

    Thread Starter elsnare

    (@elsnare)

    Hi David!
    I modified the code to fit my needs, building it around custom field values:

    $args= array(
    'meta_query' => array(
    array(
    'key' => 'type',
    'value' => 'apple',
    ))
    );
    $pagelist = get_pages($args);
    $pages = array();
    foreach ($pagelist as $page) {
       $pages[] += $page->ID;
    }
    $current = array_search(get_the_ID(), $pages);
    $prevID = $pages[$current-1];
    $nextID = $pages[$current+1];
    
    <a href="<?php echo get_permalink($prevID); ?>" title="<?php echo get_the_title($prevID); ?>">Previous</a>
    
    <a href="<?php echo get_permalink($nextID); ?>" title="<?php echo get_the_title($nextID); ?>">Next</a>

    The above script works, but it completely ignores the meta key/value parameters to narrow down the list of pages to jump to.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Next/Prev page navigation’ is closed to new replies.