WordPress Paradox – Normal posts not being queried

I am in a situation that i can’t figure out. I am running a WP 3.4.2 on a site with multiple custom post types. The normal posts are displayed in the blog section and are in a category called blog with different subcategories.

Blog posts and another post type called ‘events’ display tags in single view. The tags display fine but when you click on a blog post tag no posts are found. Tags related to events work as expected.

Read More

The really weird thing is in admin. when I search a tag that is related to a normal post, it finds it and counts how many posts it has, but when clicking on the number of posts is says “No posts found.”. With the tags related to events this never happens.

Also, categories have the same problem.. display just posts from events..

Also I tried to make another post type called “blogposts” to display on the blog page instead of normal posts but same sad story.

As far as I see in the code, in archive.php and tag.php, normal posts are not returned from the query, just events get through.

I have this in functions.php

function namespace_add_custom_types( $query ) {
    if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', array('post', 'events', 'blogposts' ));
        return $query;
    }
}
add_filter( 'pre_get_posts', 'namespace_add_custom_types' );

Any ideas would be really welcomed.
Thanks!

Related posts

Leave a Reply

1 comment

  1. This is a weird problem. Most likely caused by a combination of plugin(s) and/or theme.
    So first we need to figure out where the problem comes from. So:

    • turn off all plugins to see if it changes.
      • Or do it one by one
    • turn off parts in functions.php in your theme.
      • turn as many off as possible and see if things change

    To find this problem we need more specific information.
    Is it your won theme or someone else’s?
    What plugins are active?
    Is this problem new, or did it just ‘popup’?

    good luck and let me know what you find 😉