Forums

[resolved] Widget - only display child categories (4 posts)

  1. extrakun
    Member
    Posted 3 years ago #

    Hi,

    Is there a widget which only display the child categories of a current category archive?

    Regards,
    kun

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    Get the PHP Exec Widget by Otto.
    http://wordpress.org/extend/plugins/php-code-widget/

    Then put this code in one of the widgets:

    <?php
    if (is_category( )) {
      $cat = get_query_var('cat');
      $parent = get_category ($cat);
      if ($parent->parent) {
        wp_list_categories ('child_of=' . $parent->parent);
        } else {
        wp_list_categories ('child_of=' . $cat);
      }
    }
    ?>
  3. extrakun
    Member
    Posted 3 years ago #

    Thanks. I try to see if I can work that into an existing widget or a mini-one.

  4. daand
    Member
    Posted 2 years ago #

    Thanks!!
    Very usefull!!!

    Can i remove the item "Categorie" which is displayed just above the child categories?
    It has probembly something to do with the css, because i cant find it in the php code...
    http://www.campingdestriene.nl/website/category/verblijfsmogelijkheden/camping-algemeen

Topic Closed

This topic has been closed to new replies.

About this Topic