go41

List subcategories in category bar of arthemia theme

von Joern am 13. Dez. 2008 | Keine 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 Manage → Categories. Each post in WordPress is filed under one or more Categories. This aids in navigation and allows posts and to be grouped with others Topic Tag: subcategories. 1 2 filter only from one category , its subcategories and its posts. About WordPress. About WordPress; SSS stallation structions. stallg is pretty easy takes only a mute or two. Upload ‘--widget’ directory to your ‘/wp-content 11. HOW TO ADD SUB-CATEGORIES 1. this tutorial, we'll show you how to add - to your newly created top menu . ( our case Help). 2. First, go to .yourdoma Tags: categories, your, wordpress,

Autor:

Du findest mich auch auf Google+, Twitter und Facebook!

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.