我在Word Press上使用了一个静态的页面,并且我希望页面能够在页面底部显示我最近的帖子。问题是,代码仅适用于某个特定的帖子,我不知道如何告诉计算机获取最新帖子并使其正确显示。这里有一个链接到我的网页,请记住它远没有完成。 Electric Car WordPress Site试图添加最近的帖子到Wordpress中的静态首页
<?php
$args = array('name' => '4th');
$query = new WP_Query($args);
while ($query->have_posts()) : $query->the_post(); ?>
<div class="post">
<!-- Display the Title as a link to the Post's permalink. -->
<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
<small><?php the_time('F jS, Y'); ?> by <?php the_author_posts_link(); ?></small>
<!-- Display the Post's content in a div box. -->
<div class="entry">
<?php the_content(); ?>
<?php // get_template_part('content', 'single'); ?>
</div>
在你的$ args - 删除名称= ....作为特别要求这个职位。你可能想在那里添加你自己的参数来确切地指定你想要的。查看http://codex.wordpress.org/Function_Reference/WP_Query获取更多信息 –
https://codex.wordpress.org/Function_Reference/wp_get_recent_posts 非常简单,只需删除您不需要的任何参数即可。 –