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 I saw on twitter that John Gardner was looking for a way to loop through his WordPress categories and then display all posts that belonged to that category How to Add WordPress Categories. WordPress is a por content management system (CMS). It was launched in 2003 and in 2011, 32.5 million people had How to create sgle post templates for use your theme. CSS | 2619 Website Templates, CSS has 2619 website templates, all templates are CSS templates, open source templates or creative commons templates. Tags: free, 2619, free, Learn the basics of usg to create a website.

Autor:

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

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.