根据帖子类型和自定义字段显示帖子页面 - WordPress
我正在尝试根据帖子类型和自定义字段显示帖子页面。
这是我到目前为止所拥有的。它似乎只显示我想要的“新”帖子类型的帖子,但现在我还想根据自定义字段值进行过滤,但我不确定如何进行。
<?php
$args = array( 'post_type' => 'new', 'posts_per_page' => 10);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content()
echo '</div>';
endwhile; ?>
我还想知道如何添加分页。
谢谢!
I'm trying to display a page of post based on the post type and custom field.
This is what I have so far. It seems to display the posts only from the 'new' post type how I'd like but now I'd like to also filter based on the custom field value and I'm not sure how.
<?php
$args = array( 'post_type' => 'new', 'posts_per_page' => 10);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content()
echo '</div>';
endwhile; ?>
Also I was wondering how I'd got about adding pagination to this.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够通过自定义字段(元)进行过滤:
此处很好地解释了自定义查询的分页:
http://weblogtoolscollection.com/archives/2008/ 04/19/分页和自定义 wordpress-loops/
You should be able to filter by custom fields (metas) with:
Pagination with custom queries is nicely explained here:
http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/