I found many similar questions but I'm still in trouble. The point is very simple: I need to retrieve all posts(exactly of post type 'post') inside a page template. I don't want to change in wordpress options -> use static page blabla and page for blog blabla. So, like always I create a new WP_Query object and start the loop:
$paged = (get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => -1,
'paged' => $paged,
'post_type' => 'post'
);
$page_post = new WP_Query($args);
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $page_post;
if ($page_post->have_posts() ) : while ( $page_post->have_posts() ) : $page_post->the_post();
[mystuff here, just for testing I use the_title();]
endwhile;
endif;
wp_reset_postdata();
foundation_pagination();
$wp_query = NULL;
$wp_query = $temp_query;
No posts are found. I have 2 articles saved, the hello world one and a test one; all over the site, I used only custom posts, this is the first time I'm using default post type. The cool thing is that if I change
'post_type' => 'fasthomepress_pt' //The custom post type I used all over the site
my page loop find everything! It's like the default post is not found anymore. I disabled all plugins (only one created by me, I thought "ehi, maybe I messed up something there), and still no posts found.
Any ideas? :D
Aucun commentaire:
Enregistrer un commentaire