[Resolved] weird problem – can't query custom posts
Hi there –
I’ve used this plugin for ages with no problem, and now for whatever reason I’m working on a theme with it and I can’t query the custom post types.
First, when I was querying the CPT (in this case, ‘proyectos’), I was wrapping each proyecto post in a div, it the query was just outputting 10 empty divs.
I thought it might be the db, so I moved my theme files to a clean install of WP with a clean db.
Installed the plugin fresh, created the post type Proyecto and left all default settings except making it hierarchical, published a post. I can view the post no problem : http://gentry1.bluestormcreative.com/proyecto/project-1/
Now I’ve got my page template set up with a loop to output this custom post type, and it is only pulling all the OTHER posts. (in this case, created by the wp example content plugin): http://gentry1.bluestormcreative.com/proyectos/
Here is my template code:
<?php get_header(); the_post(); ?> <section id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <h1><?php the_title(); ?></h1> <?php global $wp_query; query_posts(array( 'post_type' => 'proyecto' )); while(have_posts()) : the_post(); ?> <li <?php post_class(); ?>><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; wp_reset_query(); ?> </main><!-- #main --> </section><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
I’ve also tried a WP_Query loop with:
$query = New WP_Query('post_type=proyecto');
but that does the same thing – no posts.
What the heck am I missing? I’m starting to feel a little crazy. I’ve tested with the default theme and this custom template, with all other plugins disabled, with wp_debug on, and also by copying the code from the plugin and putting it in my function file and then turning the plugin off – nothing works so far.
Any ideas would be SO greatly appreciated!! Thank you in advance!!
- The topic ‘[Resolved] weird problem – can't query custom posts’ is closed to new replies.