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:


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' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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