【发布时间】:2017-07-07 17:31:40
【问题描述】:
我目前有一个 CPT 更改日志,在我的自定义侧边栏上,我想仅显示此 CPT 的存档,而不是所有其他帖子的存档。
例如:
2017 年 1 月 -> 应仅显示 CPT 更改日志帖子 以此类推。
这是我迄今为止尝试过的:
function custom_changelog_getarchives_where($where)
{
$where = str_replace("post_type = 'post'", "post_type IN ( 'post',
'changelog' )", $where);
return $where;
}
add_filter('getarchives_where', 'custom_changelog_getarchives_where');
上面的 sn-p 现在返回我的 CPT 的档案,但它也包括正常的帖子
如何只显示 CPT?
【问题讨论】:
-
$where = str_replace("post_type = 'post'", "post_type = 'changelog' ", $where);
标签: php wordpress wordpress-theming