请知悉:本文最近一次更新为 4年 前,文中内容可能已经过时。

有些分类不想出现在WordPress的Recent Posts中,如何处理呢?

其实方法很简单,只需要在主题的functions.php文件尾部添加如下代码即可:

function filter_widget_posts_args( $args ) {
$exclude = "要排除的分类ID";
$args["category__not_in"] = $exclude;
return $args;
};
add_filter( 'widget_posts_args', 'filter_widget_posts_args' );

如果要排除的是多个分类,如1,2,则$exclude = "array(1,2)"

以上方法参考自:
https://www.thewordcracker.com/en-us/how-to-exclude-specific-post-categories-from-the-recent-posts-widget-in-wordrpess/


如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《WordPress 如何过滤Recent Posts中的分类》相关的博文:


留言

avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌