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.

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!


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

Tags: Mysql / Wordpress

Similar questions

Wordpress custom post types and categories, posts not showing up from custom post types when queried in index.php
I have a set of custom post types in my wordpress theme, and a category named Home, to show particular posts from all post types i wish on main index.php template page. What i am doing is adding the custom post type like this in my functions.php - and then querying my posts in room.php(template file) like - which works fine. But when in my admin pa...
Add content between Wordpress queried posts
I am wondering how I can add something between posts being queried in Wordpress through this method: Is there a way I could add something simple, like say a <hr> between the two posts being pulled?
Wordpress - wp-query to list posts by custom field from PHP/MySQL queried array
I have a complicated question, hopefully I can explain it adequately. We currently have a wordpress site with hundreds of "Incentive" posts. Each of these "Incentive" posts contain a custom field titled, "Incentive ID". I want to display a page of "recommended incentives" based on a list of "Incentive ID's" that come from a PHP/MySQL query in a sep...
How do I reorganize wordpress posts by author after they've been queried?
I have a page that by default lists posts by chronological order. After the page is loaded, I want the user to be able to click on a button that will sort the posts by author alphabetically, then back to chronologically if desired. Is there a way to do this without sending a new query each time?
Get categories of queried posts
I queried posts from an array of IDs: Now I want to display a form with checkboxes for the categories of these queried posts. For example if there are two posts from the category "Drama" I dont want the "Comedy"-Category-Checkbox to be displayed. The problem: As there is no post__in parameter for get_categories, I have no idea, how I can do this.
Actions that Run on Admin Edit Page Load After Posts Are Queried
What actions run on the edit page in the admin section of a post type? i.e. xyz.com/wp-admin/edit.php or xyz.com/wp-admin/edit.php?post_type=shop_order (custom post type) I need to run a function when the page loads, after the query has performed to get all of the posts that will be displayed on the edit page. What action should I use for this? Tha...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.