0
我想在前面的静态页面中显示特定的帖子标题/内容。请记住并非所有帖子都是特定的。因此,任何人可以指导我如何做..在wordpress的首页显示特定的帖子标题
我想在前面的静态页面中显示特定的帖子标题/内容。请记住并非所有帖子都是特定的。因此,任何人可以指导我如何做..在wordpress的首页显示特定的帖子标题
是的,你可以通过传递后IDS与阵列获得头版具体职位包括参数这样的事情,
<ul>
<?php
global $post;
$args = array(
'offset'=> 1,
'include' => array(1,2,3) // PASS POST ID IN ARRAY
'post_type' => 'post',);
$myposts = get_posts($args);
foreach ($myposts as $post) : setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php the_content(); ?>
</li>
<?php endforeach;
wp_reset_postdata();?>
</ul>
希望这个作品。
<?php
$titles=array();
$contents=array();
$links=array();
// the query
$the_query = new WP_Query(array(
'posts_per_page' => 3,
));
?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?php $titles[]=get_the_title(); ?>
<?php $contents[]=get_the_content(); ?>
<?php $links[]=get_the_permalink();?>
<?php endwhile; ?>
,现在印在我的网页价值的地方我想
<?php echo $titles[0]; ?>
<?php echo $titles[1]; ?>
<?php echo $titles[2]; ?>
而且同其他声明数组。 :)
谢谢,这为我工作。 –
,但你能告诉我如何得到前3或2个职位的ID,而不分配他们在array.like自动它得到顶级2或3职位的ID。 –
如果您想动态显示帖子而不是静态ID,那么您不需要在查询中添加'include'参数。只需将其删除并替换为''posts_per_page'=> 3,'。它返回你前3名最新职位。 –