Results 1 to 2 of 2

Thread: Need to display only primary category

  1. #1
    Thread Starter
    Expired Customer sonicxxx's Avatar
    Join Date
    Aug 2015
    Posts
    96
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Need to display only primary category

    Hi, I have "VIP ads" that have multiple categories (1,3,6) and I'd like to show on the homepage only the primary category and whenever someone picks some category (like 1 or 3 or 6) to show them that ads that we have an all categories with current name of cat. I mean the Ad have all categories, on homepage show only the Primary cat, on other categories show their cats (on cat 1 show "1", on cat 3 show "3" etc...).

    I found in the wordpress forum the code
    PHP Code:
    function the_category$separator ''$parents ''$post_id false ) {
        echo 
    get_the_category_list$separator$parents$post_id );

    witch says that if Ill add
    PHP Code:
    $parents 'single' 
    that should be fine, but when I change it, nothing happens.

    I'v tested allso and that one on file wp-content/themes/classipress/includes/actions.php line 163
    PHP Code:
    <?php the_category(', '); ?>
    with this code:
    PHP Code:
    <?php $parentscategory ="";
    foreach((
    get_the_category()) as $category) {
    if (
    $category->category_parent == 0) {
    $parentscategory .= ' <a href="' get_category_link($category->cat_ID) . '" title="' $category->name '">' $category->name '</a>, ';
    }
    }
    echo 
    substr($parentscategory,0,-2); ?>
    with no results.
    Please Help.

  2. #2
    Moderator ovidiubica's Avatar
    Join Date
    Mar 2011
    Posts
    5,749
    Thanks
    240
    Thanked 1,062 Times in 1,000 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. category >> subcategory - 1 >>> Sub category Level 2 display
    By joydeziners in forum ClassiPress General Discussion
    Replies: 0
    Last Post: January 30th, 2017, 09:01 AM
  2. [SOLVED] Category : Make Primary feature
    By andreuerj in forum Help Using Vantage (Legacy)
    Replies: 4
    Last Post: June 8th, 2016, 06:34 PM
  3. [MOD NEEDED] Display Category/Sub Category count matching the search criteria
    By rishabgarg in forum ClassiPress General Discussion
    Replies: 0
    Last Post: May 4th, 2016, 10:16 PM
  4. Replies: 2
    Last Post: October 21st, 2013, 01:40 AM
  5. Replies: 3
    Last Post: June 12th, 2012, 08:36 PM