WordPress查询某年某月文章的SQL语句

WordPress查询某年某月文章的SQL语句,第1张

WordPress="superseo">ss查询某年某月文章的SQL语句

本文详细介绍了WordPress查看某年某月文章内容的关键SQL语句,朋友们一定要参考。

使用$wpdb自定义查看可以调用某年的月度存档,例如调用2014年的月度存档的代码如下所示。

复制下面的代码://getarchivebyyear
global$wpdb,$wp_locale
$year=2014;
$query="SELECTDISTINCTMONTH(post_date)FROM$wpdb->;其中`post_type`='post'和`post_status`='publish'和YEAR(post_date)=$year的帖子按`month`DESC'排序;
$months=$wpdb->;get_results($query);
echo'<;ul>';
echo'<;李><ahref=""。'get_year_link($year)。'">。'sprintf('%d',$year)。'</a>;;
echo'<;ulclass="month-list">;
foreach($monthsas$month){
$text=sprintf(__('%1$s'),$WP_locale->;get_month($month->;月));
echo'<;李><ahref=""。get_month_link($year,$month->;月)。”">。$text。</a>;</李>;
}
echo'<;/ul>;</李></ul>;;


输出以下内容:

复制以下代码:<;李><ahref="http://yourdomain.com/2013/">;2013年</a>;
<;ulclass="month-list">
<;李><ahref="http://yourdomain.com/2013/11/">;十一月

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/772464.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存