How to show the Parent Category in the post an ad process for cp3.4/SR theme
This is a tutorial on how to show the Parent Category in the post an ad process for cp3.4/SR theme.
I'm posting it here so its easy to find for people that use cp3.4 and the simply responsive theme.
I will continue to add little customisation tweaks for CP/SR to this child theme forum as and when I get the chance/time as it allows me to find the things I forget due to gaps in working on my site.
If Sarah wants to add them to her theme - that's fine by me.
Anyway here goes.
Massive thanks to Omar for figuring this out in this post.
http://forums.appthemes.com/classipr...post-ad-69291/
It will also work with standard classipress (no child theme usage)
Add this custom function to your child theme functions.php file. Or the classipress functions.php if not using a child theme.
This function returns the category hierarchy.
// Show Parent Category in the post an ad process
function cp_get_category_parents($cat_id)
{
$chain = '';
$delimiter = '/';
$term = get_term_by( 'id', $cat_id, APP_TAX_CAT);
$parent = $term->parent;
while ( $parent ):
$parents[] = $parent;
$new_parent = get_term_by( 'id', $parent, APP_TAX_CAT);
$parent = $new_parent->parent;
endwhile;
if ( ! empty( $parents ) ):
$parents = array_reverse( $parents );
foreach ( $parents as $parent ) :
$item = get_term_by( 'id', $parent, APP_TAX_CAT);
$chain .= $item->name.$delimiter.' ';
endforeach;
endif;
$chain .= $term->name;
return $chain;
}
Then using the theme editor/your favourite text editor, please go to
wp-content/themes/classipress/ and open the file
form-listing-details.php
In that file search for <?php echo $category->name; ?>
Replace it with <?php echo cp_get_category_parents($category->term_id); ?>
Voilą. Job done and this is the result.
Attachment 13981
Enjoy