Missing _post-carousel.php file...but I see the carousel on the page!

Hello,

My problem actually has two parts. I wanted to originally change the posts in the post carousel to be the most recent. I did a Google search and figured out how this could be accomplished in the support archives. It said to create a PHP file called _post-carousel.php and upload it into /wp-content/themes/x-child/framework/views/ethos.

Should be easy enough right? However, here enters my second problem. There is no ethos folder there. I also checked in the X theme folder for the original copy of this file or anything pertaining into the carousel, but there is nothing. The carousel shows up fine on the page and has the options it should have, so I am baffled.

Where is the file or the ethos folder? How is the carousel even working if I can’t find any file related to it? And lastly, how do I get the posts in the post carousel to be the most recent?

The website address is: http://www.audacitymagazine.com/

I appreciate all of your help! Thank you.

Hi @djmnhistory,

Thanks for writing in.

The file location is transferred to this file path due to future plans.

x\framework\legacy\cranium\headers\views\ethos

To display it on latest post, use this code below

<?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',
      'meta_key'       => '_x_ethos_post_carousel_display',
      'meta_value'     => 'on'
    );
    break;
	
	
	
}
$args['orderby'] = 'DESC';
$args['orderby'] = 'date';
?>

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

Adjust the switch argument to achieve the best customization that you want to achieve in the result.

Let us know how it goes.

Thanks.

Thanks so much! It worked! :slight_smile:

1 Like

Hi @djmnhistory,

Happy to hear that.

Feel free to ask us again.

Thanks.