通过号码检索某些帖子? [英] Retrieve certain posts by their number?

查看:70
本文介绍了通过号码检索某些帖子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过某些号码来称呼某些帖子,以将其作为特色帖子放置在模板的特定位置? 我已经读过有关粘性帖子的信息,但是我大约有3个地方可以放置特色帖子,我想我需要一个循环才能按照我定义的编号获取帖子.

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.

任何帮助吗?!

推荐答案

<?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();
?>

这篇关于通过号码检索某些帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆