0

I tried it all and since i am not so good in this coding, I want to hide a category and his posts from the homepage I tried all plugins especially wp hide post but it needs pro version and seems Support is not answering on my emails so i rather do not buy that i tried the code that i found everywhere see below,

however my theme has his own categories for products (taxonomy=download_category&post_type=download) the code i found and tried in many ways to change

function exclude_category($query) {
    if ( $query->is_home() ) {
        $query->set( 'cat', '-156, -58,-154,-155' );
    }
    return $query;
}
add_filter( 'pre_get_posts', 'exclude_category' );


so 1 of the things i tried was

function exclude_category_download($query) {
if ( $query->is_home() ) {
$query->set('cat', '-156, -58,-154,-155');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category_download');

I am completely lost could really use some help

5
  • Is your theme is ready made theme or you create custom one? Jan 3, 2019 at 10:01
  • is a ready made theme
    – paco
    Jan 3, 2019 at 10:02
  • 1
    Then please open your admin panel and go to Pages section and search for Home page, i think there is option for hide that posts section so please check once Jan 3, 2019 at 10:21
  • @PratikPatel We can also add checking home page condition before show post and category code. developer.wordpress.org/reference/functions/is_home Jan 3, 2019 at 11:12
  • @paco You have to check there are template page for home page. There may be any other file included the code of post and category. If you find this code then you have to add home page related condition on that code. Jan 3, 2019 at 11:17

2 Answers 2

0

Have you tried Ultimate Category Excluder plugin? You can use it to exclude categories very easily. You just need to select the categories that you want to remove. It can be very useful, as you are not comfortable with coding.

Also, you can try using the following codes:

function exclude_category_home( $query ) {if ( $query->is_home ) {$query->set( 'cat', '-156, -58,-154,-155' );}return $query;}add_filter( 'pre_get_posts', 'exclude_category_home' );

You can find more information about the method of hiding category here.

0

@PratikPatel oh my god why i did not think of that, most easy ever thank you so much...

regarding ultimate category excluder i tried them all, not made for that, well only wp hide post showed he could see that other kind of categories, but they not answer

for some one maybe works SIMPLY EXCLUDE, i just found it and it did show up in the special pages that others do not show, however it did not work anymore at least not for me https://wordpress.org/plugins/simply-exclude

Thank you so much all, saved me some grey hair here! however

i have another website theme etc. from wpjobster, seems i am not able to do that trick... there are some adult categories i would like to exclude

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.