I need to use (on my theme) multi blog pages (Posts page). My idea is using page template for it, but I have a problem with getting all posts in template file. Regular loop the_post() from index.php file does not work.
I created blog-template.php file based on http://ift.tt/1orySJr idea and code of my file looks:
/*
Template Name: Blog (Posts page)
*/
$args = array( 'post_type' => 'post' );
$post_list = new WP_Query( $args );
while ( $post_list->have_posts() ) {
$post_list->the_post();
get_template_part( 'templates/content', get_post_format() );
}
but I think.. it is not perfect solution to use WP_Query(). Is it possible to do it better? and mark my blog-template.php file as a special file with Blogposts in order to the_post() function works?
regards
Marcin from Poland
Aucun commentaire:
Enregistrer un commentaire