0
我正在为我的wordpress启用site.being创建一个相关的文章后功能,它是面向一些问题的PHP和WordPress新手。 虽然我可以用wordpress的功能来显示作者的相关帖子,但由于网站是托管的作家谁没有任何配置文件的文章,并且有很多这样的作者,所以当为作者创建一个新的帖子时,我们倾向于将自定义字段保存为author_email。 所以在此基础上,我们要显示所有文章被发表,particual author.i使用get_posts尝试()方法getPost()方法和分页
<?php
$args = array('meta_key' => 'author_email', 'meta_value' => '[email protected]');
$authorposts=get_posts($args); ?>
<div id="content">
<span class="breadcrumbs"><a href="<?php echo get_option('home'); ?>/">Home</a> » <?php the_category(', ') ?></span>
<?php if (count($authorposts) > 0) {
foreach ($authorposts as $post): setup_postdata($post) ?>
<div id="headline_author">
/*
showing post tilte with image and some part of it
*/
<div class="clearfloat"></div>
</div>
<?php endforeach; ?>
<div class="post-nav">
<div class="previous"><?php previous_posts_link('‹ Previous Page') ?></div>
<div class="next"><?php next_posts_link('Next Page ›') ?></div>
</div>
<?php
} else {
echo '<p>No articles by this user</p>';
}
?>
</div>
它显示前5个结果,并到下一个页面的链接,但是当我点击下一页显示它已经到了第二页,因为它在URL上也是可见的,但它显示了它在第一页中显示的结果。 我是一个想法,我已经写在同一页面上的查询从头再次执行,但不知道如何解决它。 因为我使用cutom字段获取帖子我可以使用简单的查询来获取帖子基于限制或offse等
任何人都可以帮助我解决这些事情,或可以指出我要正确做到这一点
在此先感谢