Change display of carousel content in Ethos

HI,

At the moment in Ethos stack, the carousel shows post from our blog. We’d like to have a carousel on our home page that displays recent posdcast episodes, rather than blog posts. I can’t find anywhere to do this. Any assistance would be great!

Thank you.

Hi,

Thanks for writing in!

To achieve that copy the file
x/framework/legacy/cranium/headers/views/ethos/_post-carousel.php

to your child theme
x-child/framework/legacy/cranium/headers/views/ethos/_post-carousel.php
then edit that file and change post-ype to podcast.

Hope that helps

This certainly helps, thank you! My only question - is it possible to have it so that the carousel shows blog posts on the blog page, and then the podcasts on the homepage? Or does editing this file mean that podcast will be shown on all carousel?

Hi,

Yes, that’s possible.

Kindly replace the code in your _post_carousel.php with this

<?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' );

$posttype = 'post';
if(is_front_page()) {
    $posttype = 'podcasts';
} 

switch ( $display ) {
  case 'most-commented' :
    $args = array(
      'post_type'      => $posttype,
      'posts_per_page' => $count,
      'orderby'        => 'comment_count',
      'order'          => 'DESC'
    );
    break;
  case 'random' :
    $args = array(
      'post_type'      => $posttype,
      'posts_per_page' => $count,
      'orderby'        => 'rand'
    );
    break;
  case 'featured' :
    $args = array(
      'post_type'      => $posttype,
      'posts_per_page' => $count,
      'orderby'        => 'date',
      'meta_key'       => '_x_ethos_post_carousel_display',
      'meta_value'     => 'on'
    );
    break;
}
?>

<?php if ( $is_enabled ) : ?>

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

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

    <?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; ?>

I added these t the original code.

$posttype = 'post';
if(is_front_page()) {
    $posttype = 'podcasts';
} 

Hope that helps.

Thanks! 've changed the code, but i can’t seem to actually activate a carousel on my front page - do you have any idea how that would be achieved?

My website is www.equitymates.com

My blog has a carousel, but i’d like one on my homepage, showing podcast episodes. Thanks

Hi there,

The change is recommended to be added in child theme, but you don’t have active child theme. Please install a child theme and add that file in the mentioned folder path x-child/framework/legacy/cranium/headers/views/ethos/

Thanks!

Thanks for getting in touch. So I’ve activated the child account. When I add the file to the file path, should it then automatically apply it to my homepage? I can’t seem to find how to actually add the carousel to the homepage?

Hi,

Yes, by adding the file with the code in it, it should automatically apply to your homepage.

I checked your site and can see the carousel already showing up on your homepage.

Maybe you are referring to post slider?

Thanks

Hi Paul,

yes, I realised I was referring to the Post Slider!

Is it possible to have the Post Slider showing Podcast Posts on the homepage, and the also showing blog posts on my blog page?

Thanks

That is possible but further custom development from here would getting outside the scope of our support. We do have an in-house custom development team that offer paid services, who may be able to assist. They can be contacted at pinnacle@theme.co if this is of interest to you.

Thank you for your understanding.