Skip to content
Public Ticket #9819

hide categories on post

Conversation thread

myofb replied

Customer Reply

Hello,

unfortunately the code isn't working anymore.
Could you please provide me with an updates version. Thanks!

Got it working again. No more help needed :)

myofb replied

Customer Reply

Will do but you guys are putting out a new release every day at the moment :)

Maybe you could add this feature in a future release of your theme if it's not that much of a deal.

Thanks for your help anyway. This ticket can be closed

PenciDesign replied

Staff Reply

Hi,

If you want to do that, you need to use child theme or write a plugin for that. But, I think simple is backup the code and change it for each updatesmile.png

Best Regards,

PenciDesign

myofb replied

Customer Reply

It's working. Thanks.

Any way to not have to change the code after every theme update?

PenciDesign replied

Staff Reply

Hi,

You can try open functions.php file and on line 1691, find this code:

foreach ( (array)$loop_cats as $category ) {
    $cat_ID = '';
    if( isset( $category->cat_ID ) && $category->cat_ID ){
        $cat_ID = $category->cat_ID;
    }elseif( isset( $category->term_taxonomy_id ) && $category->term_taxonomy_id ){
        $cat_ID = $category->term_taxonomy_id;
    }
    if( $cat_ID == $excluded_cat ){
        continue;
    }
    if( $show_pricat_first ){
        if( in_array( $category->term_id, $cat_show_arr ) ){
            continue;
        }
        $cat_show_arr[] = $category->term_id;
    }
    if ( $first_time == 1 ) {
        echo '<a class="penci-cat-name" href="' . get_category_link( $category->term_id ) . '" rel="category tag">' . $category->name . '</a>';
        $first_time = 0;
    }
    else {
        echo wp_kses( $separator, penci_allow_html() ) . '<a class="penci-cat-name" href="' . get_category_link( $category->term_id ) . '" rel="category tag">' . $category->name . '</a>';
    }
}

and change it to:

foreach ( (array)$loop_cats as $category ) {
    $cat_ID = '';
    if( isset( $category->cat_ID ) && $category->cat_ID ){
        $cat_ID = $category->cat_ID;
    }elseif( isset( $category->term_taxonomy_id ) && $category->term_taxonomy_id ){
        $cat_ID = $category->term_taxonomy_id;
    }
    if( $cat_ID == $excluded_cat ){
        continue;
    }
    if( $show_pricat_first ){
        if( in_array( $category->term_id, $cat_show_arr ) ){
            continue;
        }
        $cat_show_arr[] = $category->term_id;
    }
    if( ! in_array( $cat_ID, array( '111', '222', '333' ) ) ){
        if ( $first_time == 1 ) {
            echo '<a class="penci-cat-name" href="' . get_category_link( $category->term_id ) . '" rel="category tag">' . $category->name . '</a>';
            $first_time = 0;
        }
        else {
            echo wp_kses( $separator, penci_allow_html() ) . '<a class="penci-cat-name" href="' . get_category_link( $category->term_id ) . '" rel="category tag">' . $category->name . '</a>';
        }
    }
}

Change value 111, 222, 333 on the above code to categories ID you don't want to show.

Best Regards,

PenciDesign

myofb started the conversation

Conversation Start

 Hello,

like your "Hide Featured Category" option for the slider I would like to hide some other categories as well.

Is there a code I could add to the functions.php or else with the specific category IDs to hide them in EVERY post? I just use them for managing my website and don't want visitors to see those.

Kind regards

Want to join this conversation or access attachments? Sign in first.