admin管理员组文章数量:1294327
I want to display 12 articles first goes the latest BUT i want to show only one post per user. For example if user A wrote 2 artticles today i want to display only the latest of his articles.
Here is the query i use
<?php
//the array 1
$args = array(
/*'posts_per_page' => 12, /* how many post you need to display */
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'blog', /* your post type name */
'post_status' => 'publish',
);
$query1 = new WP_Query($args);
?>
So my code now after the comments is like this
<?php
$args = array(
'posts_per_page' => 12, /* how many post you need to display */
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'blog', /* your post type name */
'group_by' => 'date',
'post_status' => 'publish',
);
add_filter( 'posts_groupby', 'one_per_author' );
$query1 = new WP_Query($args);
?>
but i still dont get the latest and some authors are 2 times
本文标签: phpWP query posts BUT show the most recent and one per author
版权声明:本文标题:php - WP query posts BUT show the most recent and one per author 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741599460a2387610.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论