Wordpress - Exclude a category from appearing in m

2019-02-15 02:22发布

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

Any ideas would be greatly appreciated

Thank you!

2条回答
混吃等死
2楼-- · 2019-02-15 02:40

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");
?> 

Put the code in functions.php of your theme.

查看更多
欢心
3楼-- · 2019-02-15 02:45

You can use a simple plugin widget instead where you can specify certain categories

http://wordpress.org/extend/plugins/custom-recent-posts-widget

查看更多
登录 后发表回答