excluding categories

Hello,

Thank you for the excellent theme! I have two questions both category exclusion oriented.

  1. Is there any way to exclude certain categories in the “Popular” tab of the Dazzling Popular Post Widget?
  2. Is there any way to exclude certain categories from the $categories = get_the_category_list( __( ', ', ‘dazzling’ ) ); function? I tried using get_the_category() instead so that I can exclude categories, but I can’t quite get it to work the same way.

Thank you in advance,
Donna

Hi Donna,

I hope you are well today and thank you for your questions.

1. Is there any way to exclude certain categories in the “Popular” tab of the Dazzling Popular Post Widget?

Currently there isn’t any builtin functionality of Popular Post Widget to exclude categories from it but we can exclude it by developing custom code if you are comfortable with it.

2. Is there any way to exclude certain categories from the $categories = get_the_category_list( __( ‘, ‘, ‘dazzling’ ) ); function? I tried using get_the_category() instead so that I can exclude categories, but I can’t quite get it to work the same way.

I didn’t find any argument of the function get_the_category_list to exclude categories from it but you can use the following function to achieve it and exclude certain categories from the result using its exclude argument.

Best Regards,
Movin

Hi Movin,

Thanks! The wp_list_categories worked perfectly. In terms of custom code, are you saying that I can develop custom code? Which file would I edit to do this?

Thanks again,
Donna

Hi Donna,

Reading excluding certain categories in the “Popular” tab of the Dazzling Popular Post Widget, you can achieve this by using the attached small plugin specially developed for you.

In the shared plugin file colorlib-plugin.php on line number 33 you will find the following line of code where you have to add the IDs of categories in the array which you want to exclude from the Dazzling Popular Post Widget.

$exclude_cats = array( 30, 39 ); // Add the comma seperated list of category IDs here.

You will find information about how to find category ID on the following pages.

https://bobwp.com/find-post-page-category-id-wordpress/

Best Regards,
Movin

Hi Movin,

Wow, thanks so much, worked like a charm.

Thanks again!
Donna

You are most welcome here :slight_smile: