Results 1 to 3 of 3

Thread: How to show the Parent Category in the post an ad process for cp3.4/SR theme

  1. #1
    Thread Starter
    Veteran bleem's Avatar
    Join Date
    Feb 2012
    Posts
    1,571
    Thanks
    103
    Thanked 205 Times in 180 Posts

    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

  2. #2
    talent's Avatar
    Join Date
    Jul 2011
    Location
    London UK
    Posts
    3,497
    Thanks
    75
    Thanked 553 Times in 502 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    $function ('CUSTOMIZATION'); } else { .DESIGN { display: awesome; }
    If you require any additional functionality or design customization, just ask. Afterall... anything is possible! However, I may not know how to implement your particular request, but if you don't ask, you don't get

    If you build it, they will come...


  3. #3
    Thread Starter
    Veteran bleem's Avatar
    Join Date
    Feb 2012
    Posts
    1,571
    Thanks
    103
    Thanked 205 Times in 180 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [MOD NEEDED] Show Parent Category in post ad process...
    By samnabz in forum ClassiPress General Discussion
    Replies: 11
    Last Post: July 14th, 2015, 07:20 AM
  2. [SQL] Show ads from the parent category
    By taradict in forum ClassiPress General Discussion
    Replies: 0
    Last Post: March 31st, 2014, 09:44 AM
  3. [MOD NEEDED] Show Parent Category and sub category in Step1
    By rlawrie in forum ClassiPress General Discussion
    Replies: 2
    Last Post: August 23rd, 2013, 08:35 AM
  4. Show Parent Category in step1
    By 100d in forum Report ClassiPress Bugs
    Replies: 1
    Last Post: August 25th, 2012, 09:02 PM
  5. Show parent category in index, search result and category
    By setempat in forum ClassiPress General Discussion
    Replies: 1
    Last Post: January 7th, 2011, 04:02 AM