Retrieve certain posts by their number?

蓝咒 提交于 2019-12-24 07:05:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!