Wordpress-排除类别出现在菜单或侧边栏小部件中 [英] Wordpress - Exclude a category from appearing in menu or sidebar widgets

查看:94
本文介绍了Wordpress-排除类别出现在菜单或侧边栏小部件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的解决方案(例如插件)来排除出现在菜单或侧边栏中的类别?
我创建了一个类别为视频的帖子,用于显示youtube视频(自然!!),但后来我意识到它们正在我的最新帖子侧边栏中显示,因此我正在寻找一种排除它们的简单方法

Is there a simple solution (e.g a plugin) for excluding categories appearing in a menu or sidebar? I created a category of posts called "videos" which display youtube videos (naturally!!) but then i realized they were displaying in my "recent posts" sidebar, and i was looking for a simple way to exclude them

任何想法都会大受赞赏

谢谢!

推荐答案

我发现 WordPress论坛中的代码似乎完全满足您的需要:

I found this code in WordPress forum which seems to do exactly what you need:

<?php
  function exclude_widget_categories($args)
  {
    $exclude = "3,6,18"; // The IDs of the excluding categories
    $args["exclude"] = $exclude;
    return $args;
  }
  add_filter("widget_categories_args","exclude_widget_categories");
?> 

将代码放入您主题的functions.php中。

Put the code in functions.php of your theme.

这篇关于Wordpress-排除类别出现在菜单或侧边栏小部件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆