Remove Specific Category from Ethos Carousel

Hello, been using the Ethos theme for a while now and love it. One question that has come up though is how to remove a specific category from the Post Carousel at the top of the page?

I currently have it set to “Random” but there is a specific category that I DO NOT want the carousel to pull from. I tried using “Featured” instead of “Random” but then it wouldn’t randomize the carousel, rather it simply put all the “Featured” posts in chronological order, which is not what I want.

So, I suppose there are two options:

  1. Leave the carousel setting to “Random” and somehow prevent it from pulling from the category I want to suppress, or…
  2. Change the carousel setting to “Featured” but somehow make it randomize the featured post in the top bar so that every time the page loads it’s different.

Thanks in advance for the help.

Hi there,

Thanks for writing in.

It’s only doable through custom template, let’s do this :slight_smile:

  1. Please install a child theme
  2. Copy this file \wp-content\themes\x\framework\legacy\cranium\headers\views\ethos\_post-carousel.php to your child theme (eg. \wp-content\themes\x-child\framework\legacy\cranium\headers\views\ethos_post-carousel.php`)
  3. Edit your copied file and replace this code block
  case 'random' :
    $args = array(
      'post_type'      => 'post',
      'posts_per_page' => $count,
      'orderby'        => 'rand'
    );
    break;

with this

  case 'random' :
    $args = array(
      'post_type'      => 'post',
      'posts_per_page' => $count,
      'orderby'        => 'rand',
      'cat' => '-12,-34,-56'
    );
    break;

Where -12, -34, -56 are the IDs of the category you wish to exclude ( - negative ). Please check to find your category ID https://www.wpwhitesecurity.com/wordpress-tutorial/find-wordpress-category-id/

  1. Upload and save it :slight_smile:

Hope this helps :slight_smile:

Perfect! Thank you so much.

Glad we were able to help :slight_smile: