Webdesign – go41

List subcategories in category bar of arthemia theme

List subcategories in category bar of arthemia theme

| 14 Kommentare

In the WordPress theme Arthemia theme by Michael Jubel is a wide category bar displaying 5 categories and their description.

Users of this theme having sub-categories will normally not see them on this bar. I will show you how to get sub-categories displayed if there are in different styles.

Let’s talk about the free Arthemia Magazine Style WordPress Theme first:

The category bar is displayed by a call in index.php between the line 49:
div id=”cat-…
and the line 58:
/div
The line 56 (span class=”cat_title”) displays the main category title, we leave it untouched
In line 57 the category description is echoed: “echo category_description”

The code I give you now will check if the displayed category has children (subcategories) and if there are it will list all of them. If there are no sub-categories, it will display nothing.

The code to insert below or instead of the category description and before the following /div is here:

<?php $sub_categories = wp_list_categories("echo=0&show_count=1&title_li=&show_count=0&style=none&use_desc_for_title=0&child_of=$category"); if ($sub_categories != "No categories") { ?>
<?php wp_list_categories("show_count=1&title_li=&show_count=0&style=none&use_desc_for_title=0&child_of=$category"); ?>
<?php } ?>

This code will give you links to your subcategories for each category displayed in the category bar. There is a <br /> tag inserted between each link.

To get the subcategories inserted in a list style you could use this code instead, getting -ul-li-li-ul around links:

<?php $sub_categories = wp_list_categories("echo=0&show_count=1&title_li=&show_count=0&style=none&use_desc_for_title=0&child_of=$category"); if ($sub_categories != "No categories") { ?>
<ul class="subcats"><?php wp_list_categories("show_count=1&title_li=&show_count=0&use_desc_for_title=0&child_of=$category"); ?></ul>
<?php } ?>

Using the list-stylecode you can style the way how the ul class subcats get displayed.

You could add anywhere into your style.css the following:

ul.subcats {list-style: none;}

with this entry in style.css you get the list-bullets removed from the sub-category list.

Yes, there are also users having the Arthemia Premium theme, they have to look in header.php and use this code (Premium only!! in header.php below echo category_description($cp_pC) close to the end of that file)

<?php $sub_categories = wp_list_categories("echo=0&show_count=1&title_li=&show_count=0&style=none&use_desc_for_title=0&child_of=$cp_pC"); if ($sub_categories != "No categories") { ?>
<ul class="subcats"><?php wp_list_categories("show_count=1&title_li=&show_count=0&use_desc_for_title=0&child_of=$cp_pC"); ?></ul>
<?php } ?>

Style the ul class subcats to get the desired results…

sub categories in category WordPress One of the things people love most about WordPress.com is into a hierarchy with top level categories and sub categories. shows adding a category with a parent. (A sub category.) Posts Categories. Each post in WordPress is filed under one or more Categories. You could add Oregon Coast and Ice Storm as sub Categories to the Photos Category This is over my head. I have a theme and want to show the on the page but cant figure it out for the hell of me. // directory home page Second shows all the to which a given post belongs under that post. You could add Oregon Coast and Ice Storm as to the Photos Tags: manage, categories, subpanel, wordpress, that clude also its or do I need to specify each because a Begners tutorial I also read that I can create as many as I

Search terms:

Related Entries

list pages custom styling in arthemia category bar

List one latest post per category on frontpage view

Category view in Arthemia optimized

Exclude one headline post from frontpage but not if is paged

List some pages with content in WordPress

Autor: JW

Freelance Webdeveloper Website Questions? Please ask in Webdesign Forum

14 Kommentare

  1. Thanks a lot Joern, I’ve got it working perfectly now. It almost looks like it’s part of the default theme.

  2. Does this drop down? I am thinking that if it does not than having children display just under the main would throw off the appearance if other categories did not have children. Is there a way to display the categories normally (with description) and a mouse over would bring the sub menu over top of the category? Maybe you could post example images of what the above codes look like or something. Just a thought.

  3. Jason, this will not drop down, just list subcategories (if there are) below the description (if there is)
    Any dropdown is always a question of styling the ul li classes as in a dropdown in the header navbar.
    Joe is using this piece of code, I actually made it because he asked in the forum about and I thought it’s a challange.
    Click on the name Joe at first comment and you will see how it could look like

    Oh, you styled Victoria (Posh Spice) Beckham on your site, now she looks great even if she “had three of her credit cards declined”

  4. What was that piece of code? Because Joe’s website no longer exists and I would love to get the info on how to turn the subcategories into drop downs.
    thanks!

  5. this code will just list subcategories and they will not drop down like a menu.
    to get a dropdown style you should try to do it in a way as sidebar dropdowns do this, select option is the key for this …

    select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'

  6. I’m sorry, where does this code go? And I know this code doesn’t do drop downs, but Joern commented that he had the code provided for someone else on their page.

    Thanks!

  7. Jacob, looking at your site I can see you put in the code already. It’s in the right place and lists your subcategories for your video games category. I guess you only have subcategories for just this cat.

    I think Joe used exactly one of the codes given above and was happy with this. He didn’t get another version with ‘dropdown’.

    You already have an ul li list, now it’s just the style and some JavaScript to get this hidden and unfold on hover, see: http://www.htmldog.com/articles/suckerfish/dropdowns/example/bones1.html

    Sure, is some work, but nothing else than any menubar unfolding on hover with the mouse.

  8. Thanks man, I got them to drop down, but My next question was how to extend the green box on the site to match the size of the box in categories. I guess the example is only that videogames displays a the subcategories in a box as large as the largest word which is playstation 3, but I would like the drop down area in green to be of equal size to the videogames ul.
    Thanks for all your help man!

  9. style the ul and li,
    just as sample:

    ul.subcats {
    font-size:20px;
    left:-999em;
    list-style-image:none;
    list-style-type:none;
    margin:5px;
    padding:5px;
    position:absolute;
    width:130px;
    }
    and
    ul.subcats li {
    can’t guess, margin? padding? width? height? – try something ..
    }

  10. yeah, I’ve been trying width padding and height, I guess I’ll try margin. Thanks man

  11. thanks so much, it really helped me to make my clients site.

  12. Pingback: Sensors Censors Senses » Blog Archive » The Making of the Blog

  13. Thanks a lot.
    It didn’t really worked for me though: if there is no subcategory, it shows “No category” instead of showing nothing.
    Do you think I did something wrong?

    • Do you use Arthemia? This code is for this theme only.
      In Arthemia in the category bar you have to set the categories first and this code is using ‘child_of=$category’ where $category is for each field one of the display_categories ( foreach ($display_categories as $category) )

      Actually by WordPress default it should show ‘No categories’ (not “No category”) if there is no child category?

      Additionally there have to be posts in each subcategory to show up, WordPress doesn’t display empty categories.

      Pls ask more questions in my forum, you are welcome: http://forum.go41.de

Leave a Reply

Pflichtfelder sind mit * markiert.

*


Website Questions? Please ask in my Webdesign Forum