Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6060251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:48:16+00:00 2026-05-23T08:48:16+00:00

Curious if anyone has tried filtering content via get_pages using a custom taxonomy. I’ve

  • 0

Curious if anyone has tried filtering content via get_pages using a custom taxonomy. I’ve got a custom post type labeled “clothing” and I’m trying to create a “Previous & Next” navigation by pulling only the “clothing” pieces that have the slug “female” in the “gender” taxonomy.

However, the Previous and Next links are pulling all clothing pieces, including my “mens” pieces.. Anyone have experience with custom taxonomy and get_pages?

<?php

$args = array(
        'sort_column' => 'menu_order',
        'sort_order' => 'desc',
        'post_type' => 'clothing',
        'post_status' => 'publish',
        'gender'=> 'female'
);

$list = get_pages($args);
$pages = array();
foreach ($list as $page) {
   $pages[] += $page->ID;
}

$current = array_search($post->ID, $pages);
$prevID = $pages[$current-1];
$nextID = $pages[$current+1];
?>

<div class="post-nav">
    <?php if (!empty($prevID)) { ?>
    <a href="?pID=<?php echo $prevID ?>" title="<?php echo get_the_title($prevID); ?>" class="left">&#171; PREVIOUS</a>
    <?php }
    if (!empty($nextID)) { ?>
    <a href="?pID=<?php echo $nextID ?>" title="<?php echo get_the_title($nextID); ?>" class="right">NEXT &#187;</a>
    <?php } ?>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:48:16+00:00Added an answer on May 23, 2026 at 8:48 am

    Used your code in conjunction with this post on advance taxonomy querying, and came up with this:

    <?php 
    
    $myquery = array(
        'post_status' => 'publish',
        'posts_per_page' => -1,
        'meta_key' => 'whatever',
        'orderby' => 'meta_value',
        'order' => 'DESC',
        'post_type' => 'your_post_type',
    );
    
    $myquery['tax_query'] = array(
        array(
            'taxonomy' => 'your_tax',
            'terms' => array('your_term'),
            'field' => 'slug',
        ),
        array(
            'taxonomy' => 'your_other_tax',
            'terms' => array('your_other_term'),
            'field' => 'slug',
        ),
    );
    
    $queryObject = new WP_Query($myquery); 
    
    while( $queryObject->have_posts() ) : $queryObject->the_post();
    
    $posts_array[] = $post->ID;
    
    endwhile;
    
    wp_reset_query();
    
    $current = array_search($post->ID, $posts_array); // returns key
    $prevID = $posts_array[$current - 1]; // get value from key 1 before
    $nextID = $posts_array[$current + 1]; // get value from key 1 after
    
    $prevLINK = get_permalink( $prevID );
    $nextLINK = get_permalink( $nextID );
    
    $prevTITLE = get_the_title( $prevID );
    $nextTITEL = get_the_title( $nextID );
    
    ?>
    
    <div class="post-nav">
        <?php if (!empty($prevID)) { ?>
            <a href="<?php echo $prevLINK; ?>" title="<?php echo $prevTITLE; ?>" class="left">&#171; PREVIOUS</a>
        <?php }
        if (!empty($nextID)) { ?>
            <a href="<?php echo $nextLINK; ?>" title="<?php echo $nextTITLE; ?>" class="right">NEXT &#187;</a>
        <?php } ?>
    </div>
    

    Works for me and it’s pretty freaking awesome… with the advanced taxonomy querying Otto explains, you can really control those next/previous links quite well. I wouldn’t have been able to figure this out without your original code though, so mad props to you and Otto!

    I’m going to try and fine tune this even further by auto detecting the terms from the page… get_the_term_list() might work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using acts_as_commentable and am curious if anyone has any good ideas on
I am curious if anyone has done a comparison between the different options out
I'm just curious to know if anyone has used (successfully) Fusion Charts with Open
I am curious to see if anyone else has run into this same issue...
I am curious to know whether anyone out there have tried mixing node.js headless
Curious if anyone has this problem: I save my (embedded) fonts in an external
Just curious if anyone has any opinions on throwing an exception in my overridden
I'm curious if anyone has found a solution to disabling the default spring-loaded iOS
Just curious if anyone has had sufficient time with WinRT yet to understand whether
I'm curious if anyone has applied workflow foundation to a DDD project and if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.