WordPress.org

Ready to get started?Download WordPress

Forums

delete a category from the sidebar (2 posts)

  1. gasmor
    Member
    Posted 6 years ago #

    sidebar have this html:

    <h2>Categories</h2>
    <ul>
    <li><a href="http://localhost/wordpress-it_IT-2.2.1/category/categ_new/"
    >categ_new</a>
    </li>
    <li><a href="http://localhost/wordpress-it_IT-2.2.1/category/my_category/"
    >my_category</a>
    </li>
    </ul>

    I tried with this code:

    function foo_bar($content, $category = null) {
      if($category->cat_name!='my_category') return $content;
    }
    add_filter('list_cats', foo_bar, 10, 2);

    but I get:

    <h2>Categories</h2>
    <ul>
    <li><a href="http://localhost/wordpress-it_IT-2.2.1/category/categ_new/"
    >categ_new</a>
    </li>
    <li><a href="http://localhost/wordpress-it_IT-2.2.1/category//"
    ></a>
    </li>
    </ul>

    I'v used this plugin too: http://djz.hu/blog/posts/372
    but i still see the category in sidebar

  2. Doodlebee
    Member
    Posted 6 years ago #

    Why don't you just use "wp_list_categories()"? You can exclude any category you want with that built-in tag.

Topic Closed

This topic has been closed to new replies.

About this Topic