WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to display posts from categories of my custom taxonomy but realy don't know how to achieve this. I am using isotope filtering which works as expected with default post categories. I can click on a particular category and it shows all posts related to that category but it doesn't work with my custom taxonomy. I can see all sub-taxonomies (thanks to Rajeev Vyas) but when I am clicking on one of them - no posts are displayed. Can you please tell me what I am doing wrong?

This is the code from my functions.php:

add_action('init', 'portfolio_register');
function portfolio_register() {
     $labels = array(
        'name' => _x('My Portfolio', 'post type general name'),
        'singular_name' => _x('Portfolio Item', 'post type singular name'),
        'add_new' => _x('Add New', 'portfolio item'),
        'add_new_item' => __('Add New Portfolio Item'),
        'edit_item' => __('Edit Portfolio Item'),
        'new_item' => __('New Portfolio Item'),
        'view_item' => __('View Portfolio Item'),
        'search_items' => __('Search Portfolio'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'menu_icon' => get_stylesheet_directory_uri() . '/images/portfolio-icon.png',
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','author','thumbnail','comments')
    register_post_type( 'portfolio' , $args );
// Custom taxonomy for Portfolio Categories (Galleries)
register_taxonomy('galleries', array('portfolio'), array('hierarchical' => true, 'label' => 'Galleries', 'singular_label' => 'Gallery', 'rewrite' => true, 'public' => true ));

And this code is from my loop.php which is my custom post type template:

 <?php /* Display filter options if homepage  */ ?>
<?php if(is_home()) { ?>
<div id="filtering-nav">
        <a href="#" class="filter-btn"><span>Filter</span></a>
                <li><a href="#all" class="all">All</a></li>
            $args=array( 'orderby' => 'name', 'taxonomy'=>'galleries' );
            foreach($categories as $category) {  ?>
                    <li><a href="#<?php echo $category->category_nicename; ?>" class="<?php echo $category->category_nicename; ?>"><?php echo $category->name; ?></a></li>
            <?php } ?>
        <div class="clearfix"></div>
<?php } ?>

<?php /* If this is the homepage, display all posts on one page  */ 
if(is_home() && get_option('show_all') && !is_search()) { query_posts('post_type=portfolio', 'posts_per_page=-1'); } ?>

<?php if (have_posts()) : ?>

Hope that my english doesn't hurt your eyes....

share|improve this question

you will need to modify the query on taxonomy term pages to get your post type


add_filter('pre_get_posts', 'filter_custom_taxonomy_posts');
function filter_custom_taxonomy_posts($query) {
    if (is_tax('Your_Taxonomy_Name')) {
        $query->set('post_type', 'portfolio');
        $query->set('posts_per_page', -1);
  return $query;
share|improve this answer
Thank you for your quick reply but unfortunately it doesn't works. Any other ideas as to what causes this problem? Thanks. – Adrian Jul 25 '11 at 21:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.