我想在wordpress中显示今天或昨天的用户数帖子。示例:
xxxx=发布2篇文章YYY=发布40篇文章
请帮帮我。
我想在wordpress中显示今天或昨天的用户数帖子。示例:
xxxx=发布2篇文章YYY=发布40篇文章
请帮帮我。
你想要什么的基本逻辑:
查找实际日期,例如$date\\u nowhttp://codex.wordpress.org/Function_Reference/get_posts_by_author_sql 与$date\\u现在具有相同的发布日期(您需要为此执行sql查询)
我目前无法测试这一点,但我相信WP_Query
从3.7开始,date_query
将执行此操作。
$args = array(
\'date_query\' => array(
array(
\'after\' => \'yesterday\',
\'inclusive\' => true,
),
),
\'posts_per_page\' => -1,
\'ignore_sticky_posts\' => true,
\'author\' => 1,
\'fields\' => \'ids\'
);
$query = new WP_Query( $args );
$posts_by_author = $query->found_posts;
再说一次,我现在无法测试,而且我还没有使用date_query
太多了。我猜。。。很多我想这可能会让你动起来。我试图在我的模板中创建一个链接,允许用户查看自己的博客帖子。我使用的代码是<li><a href=\"?author=<?php the_author_ID(); ?>\">test</a></li> 但这只会让我?author=