Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When I select a category from the head navigation bar in a database http://www.taracomplementos.com/tara/, the default display is all the items of the DB, and you must select one of the categories inside of the page to see related articles. I wish I knew how to have displayed ONLY the items belonging to a specific category. I think that the trick must be in these lines, but I can't figure out how to modify it:

        <div class="sort">
        <ul id="portfolio-control">
            <li class="segment-1"><!-- changed All for todo --><a class="active all" data-value="all" href="#"><?php _e('todo', 'ux') ?></a></li>
            <?php wp_list_categories(array('title_li' => '', 'exclude' => $excludecat,'taxonomy' => 'skill-type', 'walker' => new Walker_Category_Filter())); ?>
        </ul>
    </div>
    <?php endwhile; else : endif; ?>
</div>
<div class="span16 gallery">
    <?php $args = array(
       'post_type' => 'portfolio',
       'orderby'=>'menu_order',
       'order'     => 'ASC',
       'posts_per_page' => '-1',
       'skill-type' => get_query_var('skill-type'),
       'tax_query' => array(
       array(
               'taxonomy' => 'skill-type',
               'field' => 'id',
               'terms' => $excludecat,
               'operator' => 'NOT IN',
               )
           ) // end of tax_query
       );
    ?>
    <?php $query = new WP_Query($args); ?>

Can anybody help me? TIA, guido

share|improve this question
add comment

1 Answer

Check if excludecat is containing category IDs or category slugs, if it is using slugs/text then change the ID field to slug.

Also define the relation to use, e.g.:

'relation' => 'AND',

Here are the parameters: http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

share|improve this answer
    
I don't get what I should do. Here goes the code: <?php $excludecat = get_post_meta($post->ID, 'thb-xclude', false); $excludecat = implode(", ",$excludecat); ?> –  Guido Fuortes Feb 28 '12 at 0:39
    
<?php $args = array( 'post_type' => 'portfolio', 'orderby'=>'menu_order', 'order' => 'ASC', 'posts_per_page' => '-1', 'skill-type' => get_query_var('skill-type'), 'tax_query' => array( array( 'taxonomy' => 'skill-type', 'field' => 'id', 'terms' => $excludecat, 'operator' => 'NOT IN', ) ) // end of tax_query ); ?> –  Guido Fuortes Feb 28 '12 at 0:45
    
refer to the taxonomy parameters link for examples on where to put the 'relation' parameter –  Tom J Nowell Feb 28 '12 at 12:56
    
No way. The 'relation' parameter doesn't change anything. The problem should not be complex for anybody with some skill of Wordpress and DB. I don't wish to have all the DB items shown when I display a category, but only the items belonging to that main category. Here goes the code, if anybody wishes to have a look: pastebin.com/xTS9xaJP. The site is www.taracomplementos.com/tara/ –  Guido Fuortes Mar 4 '12 at 7:08
    
you MUST define the relation parameter, regardless of whether it fixes your issue, it is expected, and has an impact. Odd I know but its good practice. –  Tom J Nowell Mar 4 '12 at 13:33
show 6 more comments

Your Answer

 
discard

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.