Post Slider for Archives - for specific category only

Hello Folks,

For the Ethos theme in Pro, when the “Post Slider for Archives” option is enabled in the theme editor, the post slider displays all the posts from ALL categories. How do I display featured posts only from the specific category of the archive page?


Hi Jeremy,

Thanks for writing in!

If I may, you are incorrect. The post slider for archives will only display items related to the archive. For example, on a category archive, the post slider will only display items with the same category. It goes the same with date, tag and other archive pages.

Hope this helps.

I wish I were incorrect my friend.

As you can see in this photo, the category archive is “potable water” but the post slider is displaying a post from the “water crisis” category

In this photo, we’re in the “aquaponics” category but the post slider is pulling something from the “rainwater harvesting” category.

I would like it to do exactly as you say, display items related to the category. But for some reason it’s pulling posts from all categories. I’m not sure if it’s a bug or if I’m missing a setting or something.

I’d appreciate any input.


Hello Jeremy,

The post slider is displaying the related category items. The “Water Crisis” category is a child and under the Potable Water category. The same goes with Aquaponics, it is under the Rain Harvesting. I might have mistakenly pointed out in reverse order. In short, the post slider in the category archive will only display the post items that belongs to the parent category which would includes the any posts under the parent category.

Hope this make sense.


I appreciate you trying to help me with the problem again. I think you’re misunderstanding. Neither the Water Crisis category or Rainwater Harvesting category are a child of any parent category. They are independent categories. They shouldn’t be showing up in the post slider of a completely different category archive, but they are.

If what you’re saying is true, that the post slider should only display posts from the same category, then there’s something else going on, because mine is posting ALL categories.

Hi Jeremy,

Do you have any child theme or may have modified the _post-slider.php file? ​To assist you better with this issue, would you mind providing us the url of your site with login credentials so we can take a closer look?

To do this, you can create a secure note with the following info:
– Link to your site
– WordPress Admin username / password

To know how to create a secure note, please check this out:

Thank you.

OK got it, thank you.

I don’t have a child theme and I don’t think I modified the post-slider.php file.

I’ll send you my login info in the secure note.

Hey Jeremy,

I have logged in and investigated the issue. It turns out that you have selected to display “Featured” in the post slider. When you select “Featured”, all the items regardless of the category will be displayed. I went ahead and changed it to “Random”. It is not display post from the same category only.

Please check your site.

Yes! That’s it. So if you set it to random it displays posts from the same category. Thanks a lot!

It actually displays all of the posts within the category when “random” is selected. Its not quite what I wanted because I have specific posts within the category that I wanted to feature. There’s no way to have it set to “featured” but post only within the category?

Hi Jeremy,

That’s possible but first you need to set-up a child theme.

After setting up a child theme, do the following.

  1. Create file _post-slider.php in wp-content\themes\pro-child\framework\views\ethos
  2. Add the code below into that file

// =============================================================================
// -----------------------------------------------------------------------------
// Outputs the post slider that appears at the top of the blog.
// =============================================================================

$is_blog    = is_home();
$is_archive = is_category() || is_tag();

if ( $is_blog || $is_archive ) :

  if ( $is_blog ) {
    $info = array( 'blog', NULL, NULL, '_x_ethos_post_slider_blog_display' );
  } elseif ( $is_archive ) {
    $type = ( is_category() ) ? 'cat' : 'tag_id';
    $info = array( 'archive', $type, get_queried_object_id(), '_x_ethos_post_slider_archives_display' );

  $slider_enabled = x_get_option( 'x_ethos_post_slider_' . $info[0] . '_enable' ) == '1';
  $count          = x_get_option( 'x_ethos_post_slider_' . $info[0] . '_count' );
  $display        = x_get_option( 'x_ethos_post_slider_' . $info[0] . '_display' );

  $blog_slider_is_enabled    = $slider_enabled && $is_blog;
  $archive_slider_is_enabled = $slider_enabled && $is_archive;
  $is_enabled                = $blog_slider_is_enabled || $archive_slider_is_enabled;

  switch ( $display ) {
    case 'most-commented' :
      $args = array(
        'post_type'      => 'post',
        'posts_per_page' => $count,
        'orderby'        => 'comment_count',
        'order'          => 'DESC',
        $info[1]         => $info[2]
    case 'random' :
      $args = array(
        'post_type'      => 'post',
        'posts_per_page' => $count,
        'orderby'        => 'rand',   
        $info[1]         => $info[2]
    case 'featured' :
      $args = array(
        'post_type'      => 'post',
        'posts_per_page' => $count,
        'orderby'        => 'date',
        'cat'            => 1,
        'meta_key'       => $info[3],
        'meta_value'     => 'on',
        'ignore_sticky_posts'	=> true


  <?php if ( $is_enabled ) : ?>

    <?php $wp_query = new WP_Query( $args ); ?>

    <?php if ( $wp_query->post_count > 0 ) : ?>

      <div class="x-flexslider x-post-slider">
        <ul class="x-slides">

          <?php if ( $wp_query->have_posts() ) : ?>
            <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

              <li class="x-slide">
                <article <?php post_class( 'x-post-slider-entry' ); ?> style="<?php echo x_ethos_entry_cover_background_image_style(); ?>">
                  <a href="<?php the_permalink(); ?>">
                    <div class="cover">
                      <div class="middle">
                        <span class="featured-meta"><?php echo x_ethos_post_categories(); ?> / <?php echo get_the_date( 'F j, Y' ); ?></span>
                        <h2 class="h-featured"><span><?php x_the_alternate_title(); ?></span></h2>
                        <span class="featured-view"><?php _e( 'View Post', '__x__' ); ?></span>

            <?php endwhile; ?>
          <?php endif; ?>


        jQuery(window).load(function() {
            controlNav   : false,
            selector     : '.x-slides > li',
            prevText     : '<i class="x-icon-chevron-left" data-x-icon-s="&#xf053;"></i>',
            nextText     : '<i class="x-icon-chevron-right" data-x-icon-s="&#xf054;"></i>',
            animation    : 'fade',
            smoothHeight : true,
            slideshow    : true

    <?php endif; ?>

    <?php wp_reset_query(); ?>

  <?php endif; ?>

<?php endif; ?>
  1. Change 1 with the category id you want to display.

  1. Make sure that your post are enabled to display in your slider

  1. Select featured in Theme Options > Ethos > POST SLIDER – BLOG

Hope that helps

Got it. I’ll look into this. Thank you so much.

You are most welcome. :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.