Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #2185305
hide categories on post
Closed

Comments

  • myofb started the conversation

     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

  •  2,700
    PenciDesign replied

    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 replied

    It's working. Thanks.

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

  •  2,700
    PenciDesign replied

    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

    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

  • myofb replied

    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 :)