• Resolved KranzKrone

    (@kranzkrone)


    Hello,

    hopefully some one can help me, because i am stuck with my Problem at the Hueman Theme. I like these Theme so much, that i use it for 4 different Projects. A big Hug for AlxMedia!

    My Problem with Hueman Theme:

    I want to exclude a Category from the Index-Page of Hueman. But i have no clue how to do that, because i am a n00b in code. Of course i searched the Web for an Answer, but everything i tried, doesn’t work.

    Where are those lines in the code, that i have to fix? Of course by using a Child-Theme!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Can

    (@candanbl0g)

    Hey,

    Just add the following code block into the functions.php file which can be found in your theme’s directory. Change the CAT_NR with the ID of the category that you want to exclude from homepage – keep the minus sign there, it is necessary. You can find the ID of the category from the Categories page in your WP Admin Dashboard – Click the category you want and then read your browser’s URL bar, there will be something like tag_ID=123. That number is the ID.

    function excludeCat($query) {
      if ( $query->is_home ) {
        $query->set('cat', '-CAT_NR');
      }
      return $query;
    }
    add_filter('pre_get_posts', 'excludeCat');
    Thread Starter KranzKrone

    (@kranzkrone)

    @can Atasever: It WORKED very well! Thank you so much. 😀

    @can Thank you! Worked also for me!

    Can

    (@candanbl0g)

    You’re welcome friends 🙂

    Thread Starter KranzKrone

    (@kranzkrone)

    It’s still working with the new Hueman v2.1.5 !

    Awesome! I’ll be using it to exclude podcasts from the main page. Thanks!

    Hello All,

    Could someone explain me what i need to do if i want to exclude more than one category

    function excludeCat($query) {
      if ( $query->is_home ) {
        $query->set('cat', '-CAT_NR');
      }
      return $query;
    }
    add_filter('pre_get_posts', 'excludeCat');

    Thanks,
    Avinash

    Ok,

    I got the answer and it can be included like this

    $query->set('cat', '-44,-331');

    Thanks,
    Avinash

    Hello 🙂

    I need to exclude category only from related posts (“You may also like”) at the bottom of the page. Could somebody help me with this?

    Original theme code looks like this:

    // Related by categories
    		if ( ot_get_option('related-posts') == 'categories' ) {
    
    			$cats = get_post_meta($post->ID, 'related-cat', true);
    
    			if ( !$cats ) {
    				$cats = wp_get_post_categories($post->ID, array('fields'=>'ids'));
    				$args['category__in'] = $cats;
    			} else {
    				$args['cat'] = $cats;
    			}
    		}

    Greetings,
    Adrian

    Hi! This may be an obvious question, but where in the functions.php file does that you provided need to go? Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Exclude a Category from Hueman Index-Page’ is closed to new replies.