Posts

Showing posts from September, 2010

How to Add the Parent Category as a Class in body_class()

<?php $class=''; /* Make it void by default */ if ( is_single() || is_category() ) { /* Only do this if we're on a single post or category page */ $category = get_the_category(); $parent = $category[0]->category_parent; $class = get_cat_name($parent); /* assign the permalink name for the parent category to the object $class */ }?> <body <?php body_class($class); /* This will add our custom class, which is void if we aren't on a single post or category page */ ?>>

How to add span tag into page navigation

<?php echo preg_replace ( '@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i' , '<li$1><a$2><span>$3</span></a>' , wp_list_pages ( 'echo=0&orderby=id&title_li=&depth=1' ) ) ; ?>