Not display selected categories from the widget sidebar list

Hi There,

I use the following code into custom_function.php to not display selected categories from the category list on the sidebar widget list.


function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( ‘cat’, ‘-1,-117,-118’ );
add_action( ‘pre_get_posts’, ‘exclude_category’ );


-1 = uncategory,
-117 = Type A
-118 = Type B

however, it still display those three categories.

What I did wrong? I am using Child Theme of Sydney.

Regards, J

Do you have any solution to my inquiry about category selection to display or not to display.
If you have any useful plugins to achieve so, please advice.

Regards, J


You can try to use AVH Extended Categories Widgets plugin in order to display certain categories in certain order.

Kind Regards, Roman.

Hi Roman,

Thank you for your advice. By using your recommended plugin, I have achieved what I wanted.

Please close this ticket as resolved.

Regards, J

You are welcome! And have a nice day :slight_smile:

Kind Regards, Roman.