WordPress.org

Ready to get started?Download WordPress

Forums

WP_Query fails on certain custom post types (1 post)

  1. doctorproctor
    Member
    Posted 2 years ago #

    Greetings - I have code that generates e.g. this page (see Recent Project Mashups and Recent Research Themes at right) which first checks to see if any instances of a custom post type exist for a given site, then displays a feed of recent posts. The code I've used, that has worked fine until recently, is e.g.

    <?php $queryfeed = new WP_Query( 'category_name='.$site.'&post_type=project-mashup' ); ?>
    <?php if ($queryfeed->have_posts()) { etc...

    What is odd is that the post type "project-mashup" no longer works in the above; same with "situated-themes" at bottom. In other words, have_posts() turns up false. (I've temporarily replaced both with "post" since there are posts for each of our sites, but this then displays an error on blank RSS feed.) But the custom post type "site-mashup" does work (this is the post type used to generate the sample page above). And another custom post type "research" also works. Both site-mashup and research are custom post types that include the site category; same with "post," and same with the other two that no longer work...these are the two I need!

    I tried a workaround using query_posts instead of WP_query, and no change. Btw, the feeds themselves are generated using the custom post type names, and work just fine, so I'm sure it's not a simple issue with the custom post type slug.

    I'm running Custom Post Types UI to generate these custom post types; no other errant behavior as far as I can see. I'm also using Advanced Custom Fields to populate the custom post types, but I doubt if this is the issue.

    Sure appreciate any ideas; thanks.

    Jim P.

Topic Closed

This topic has been closed to new replies.

About this Topic