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.

In my theme, I registered a taxonomy by the name of tax_groups for a custom post type named custom_items. So the following URL was returning the lastest custom_items http://website.com/custom_items/

The Search widget was also working perfectly fine but not Tag and Taxonomy links like these:

http://website.com/tag/a_random_tag/
http://website.com/tax_groups/a_random_group/
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I had to modify queries before they run. So the best practice was to add the following code to function.php:

if (!function_exists('my_theme_filter')) {
    function my_theme_filter( $query ){

    if ( $query->is_main_query() )
        if ( $query->get( 'tag' ) OR is_search() )
            $query->set( 'post_type', array( 'artprim_item' ) );

    //echo '<pre>'; print_r($query); echo '</pre>';

    return $query;
}}
add_filter( 'pre_get_posts', 'my_theme_filter' );
share|improve this answer
1  
I wanted to mention that the method described in [this question] (wordpress.stackexchange.com/questions/28145/…) solved the problem for me. –  JPollock Jan 8 '13 at 6:52
add comment

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.