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 ://wpsites.net/wordpress-tips/show--categories-for-parent-category-on-archive-page/ This tutorial shows you how to display a list How can I get all subcategories from a certain category? List all subcategories from category. get subcategory of a parent category in wordpress? 1. Rachel McColl is a developer who writes books, articles and tutorials about web gn and development, with a focus on and on Function Reference/the category « WordPress Displays a lk to the or a post belongs to. This tag must be used with The Loop. (strg) (optional) Text or character to display Tags: function, reference/the, category,

Autor:

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

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.


This site uses Akismet to reduce spam. Learn how your comment data is processed.