Looping custom posts on front page
-
Hey guys,
Just wondered if anyone can help me please,
i have created a custom post called “book” and have entered content on that custom type i am trying to display the 4 most recent posts on my front page along with their thumbnails but what every i seem to add makes my front page break what am i doing wrong?this is my code currently that works
<div id=”container”>
<div id=”content”>
<?php
$type = ‘book’;
$args = array (
‘post_type’ => $type,
‘post_status’ => ‘publish’,
‘paged’ => $paged,
‘posts_per_page’ => 4,
‘ignore_sticky_posts’=> 1
);
$temp = $wp_query; // assign ordinal query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
echo ‘<h2>’;
the_title();
echo ‘</h2>’;
echo ‘<div class=”entry-content”>’;
the_content();
echo ‘</div>’;
endwhile;
else :
echo ‘<h2>Not Found</h2>’;
get_search_form();
endif;
$wp_query = $temp;
?>
</div><!– #content –>
</div><!– #container –>i really want to add the thumbnail above the <h2> code but i cant seem to make it work any way i do it
- The topic ‘Looping custom posts on front page’ is closed to new replies.