问题
How can I call certain posts by their number to place them as featured posts in specific places of my template ? I've read about sticky posts , But I have about 3 places to place my featured posts and I guess I need a loop to get posts by their number I defined.
Any HELP ?!
回答1:
<?php
// The Query
$query = new WP_Query( 'p=7' );
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
// Reset Post Data
wp_reset_postdata();
?>
来源:https://stackoverflow.com/questions/5924489/retrieve-certain-posts-by-their-number