It is possible to exclude categories from a blog

edited June 2023 in Blog

Hello, I have to set up a blog that includes two categories with an excluded category. How can i do it?


I try to explain better. I have, for example, two articles: the first one has category A and B, the second one has category A and C. I need to show in a Blog only categories A and B, excluding C. It is possible?


I'd like to exclude the category, not exclude every single post of the C category. I hope I explained myself.

I precise that I cannot setup exclude categories on a blog page, because i need to insert the blog shortcode in a tabs element. Here is the link https://mec-partners.it/genus/mostre-eventi/fattori-lumanita-tradotta-in-pittura/


Thank you

Marco

Comments

  • Hi,

    There is an option to hide a category from filters with CSS, but there is no setting to exclude this category in the theme options.

    However, I am not sure to what part of your website you refer to. Can you attach screenshot showing that, please?


    Best regards

  • Here's the page screenshot

    https://mec-partners.it/genus/mostre-eventi/fattori-lumanita-tradotta-in-pittura/

    In the EDUCATION tab I have two blog shortcodes. The goal is to show one category per shortcode. The problem is that the blog items share one category. I try to explain better.

    Under "BAMBINI" I want to show up only post with the "bambini" category.

    Under "ADULTI" I want to show up only post with the "adulti" category.

    The problem is that both posts of the two categories share with each other another category (palazzo-fava) which is the location where both the events are staged. Hope this is more clear for you.


    Thank you

    Marco

  • I tried ti insert in the shortcode exclude_category="" but didn't work.

  • In the blog shortcode, you can choose which category you want to display:

    But you can also use a CSS code:

    .tabs_wrapper #tab-6483015b02728-2 .column_filters:nth-of-type(1) .blog_wrapper .post:not(.category-bambini-fava){
       display: none;
    }
    

    Put it in Betheme -> Theme options -> Custom CSS & JS -> CSS.

    To affect the second shortcode, you need to change nth-of-type(1)to nth-of-type(2), and change the category name.


    Best regards

  • Unfortunately it didn't work. the issue is that the two blog post you see in the page are sharing two categories that I have to insert in the shortcodes as well.

    In fact, the post with category bambini-fava has also the categories palazzo-fava and fattori.

    The post with category adulti-fava has also the categories palazzo-fava and fattori.


    I just want to EXCLUDE a category from a shortcode.

    The first method you showed to me allow only to select a category to show, not to hide. I need to hide a category. How can I do it?

  • class="post post-item isotope-item clearfix post-91 type-post status-publish format-standard has-post-thumbnail hentry category-adulti-fava category-fattori category-palazzo-fava"

  • edited June 2023

    the issue is that the id of the tabs element changes every time I refresh the page

  • So instead, use the CSS code I have sent, but remove :not and put there the category you want to hide.

    .tabs_wrapper .column_filters:nth-of-type(1) .blog_wrapper .post.category-bambini-fava{
       display: none;
    }
    

    Best regards

  • edited June 2023

    thank you very much Phil, it seems to solve the problem.

    Another question: can i refer this line to a single page with .page-id-xxx?


    .page-id-51 .tabs_wrapper .column_filters:nth-of-type(1) .blog_wrapper .post.category-bambini-fava{

      display: none;

    }


    Precisely, I need to refer this code to a single portfolio post

    This one https://mec-partners.it/genus/mostre-eventi/fattori-lumanita-tradotta-in-pittura/

    it has id 51

  • Sure, you can do it.

    Page id does not change, so you should not encounter any problems with that.


    Best regards

Sign In or Register to comment.