ETHOS Post slider for blog display options

Hello,
for the post slider for the blog with Ethos, the options are Featured, Random, Most commented. Featured is almost helpful, but then each time you have to go in and unclick the featured that you no longer want. Is there a way to have this show the MOST RECENT posts in a certain category instead??

Thanks
Rena

Hello There,

Thanks for writing in!

To show the MOST RECENT posts in a certain category in the post carousel, since you have your child theme active and ready, please follow the following steps below:
1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file

<?php

// =============================================================================
// VIEWS/ETHOS/_POST-CAROUSEL.PHP
// -----------------------------------------------------------------------------
// Outputs the post carousel that appears at the top of the masthead.
// =============================================================================

GLOBAL $post_carousel_entry_id;

$post_carousel_entry_id = get_the_ID();

$is_enabled = x_get_option( 'x_ethos_post_carousel_enable' ) == '1';
$count      = x_get_option( 'x_ethos_post_carousel_count' );
$display    = x_get_option( 'x_ethos_post_carousel_display' );

switch ( $display ) {
  case 'most-commented' :
    $args = array(
      'post_type'      => 'post',
      'posts_per_page' => $count,
      'orderby'        => 'comment_count',
      'order'          => 'DESC'
    );
    break;
  case 'random' :
    $args = array(
      'post_type'      => 'post',
      'posts_per_page' => $count,
      'orderby'        => 'rand'
    );
    break;
  case 'featured' :
    $args = array(
      'post_type'      => 'post',
      'posts_per_page' => $count,
      'orderby'        => 'date',
      'category_name' => 'news'
    );
    break;
}

?>

<?php if ( $is_enabled ) : ?>

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

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

    <ul class="x-post-carousel unstyled">

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

          <li class="x-post-carousel-item">
            <?php x_ethos_entry_cover( 'post-carousel' ); ?>
          </li>

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

      <?php wp_reset_query(); ?>

      <script>

      jQuery(document).ready(function() {
        jQuery('.x-post-carousel').slick({
          speed          : 500,
          slide          : 'li',
          slidesToShow   : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_extra_large' ); ?>,
          slidesToScroll : 1,
          rtl            : <?php echo json_encode( is_rtl() ); ?>,
          responsive     : [
            { breakpoint : 1500, settings : { speed : 500, slide : 'li', slidesToShow : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_large' ); ?> } },
            { breakpoint : 1200, settings : { speed : 500, slide : 'li', slidesToShow : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_medium' ); ?> } },
            { breakpoint : 979,  settings : { speed : 500, slide : 'li', slidesToShow : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_small' ); ?> } },
            { breakpoint : 550,  settings : { speed : 500, slide : 'li', slidesToShow : <?php echo x_get_option( 'x_ethos_post_carousel_display_count_extra_small' ); ?> } }
          ]
        });
      });

      </script>

    </ul>

  <?php endif; ?>

<?php endif; ?>

and make sure that the category name in the code above is the category that you want to display

3] Save the file named as _post-carousel.php
4] Upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/legacy/cranium/headers/views/ethos/

You will have to create the folder path since it does not exist yet in your child theme.

Please let us know how it goes.

Thank you, Im using pro-child and i added all of the folders ( legacy/cranium/headers/views/ethos/ )
and put the file in there. But nothing happened. : /

Is it bc im using PRO?
The site is: http://pzu.a90.myftpupload.com/

Thanks
Rena

Hey Rena,

The code @RueNel gave is for the Ethos Carousel. What you need is for the Post Slider. But, I checked your News & Features at http://pzu.a90.myftpupload.com/featured-news/ and you neither have a carousel nor a slider. You have a carousel in your front page but it’s not powered by the theme. Please setup the Ethos slider.

Once setup, you will need to create this folder in your child theme /x-child/framework/views/ethos/ then create a _post-slider.php file. Next, copy the contents of the file and above the <?php $wp_query = new WP_Query( $args ); ?> line, add this block of code.

<?php
      $args = array(
        'post_type'      => 'post',
        'posts_per_page' => $count,
        'orderby'        => 'date',
        'category_name'  => 'edge-case-2',
        'ignore_sticky_posts'	=> true
      );
?>

When followed correctly, you should achieve the same result as in this screencast.

Hope that helps.

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