Ethos Stack Post Slider

I’m running Ethos stack on Pro and am using the post slider above the masonry on my blog page. I’d also like to run it on my (static) home page too.
I found this older thread:


which gives advice on modifying within a child theme, but I can’t locate the wp-header.php file in order to append the code. Please could you point me in the right direction

Hi there,

Since the update for X 5, the location of the wp-header.php for ethos was moved to:

/wp-content/themes/x/framework/legacy/cranium/headers/views/ethos

Hope this helps.

And would that be the right file for me to modify working in Pro, rather than X?
(The site was originally designed in X, but I migrated it to Pro when it was released)

Hello There,

Sorry for the confusion. Since you are using Pro, you will need to install a Pro-Child theme first and then, modify the template in your child theme. You can locate the header files in:

/wp-content/themes/pro/framework/legacy/cranium/headers/views/ethos/

In you child theme, you will have to create the folder path and insert your modified templates:

/wp-content/themes/pro-child/framework/legacy/cranium/headers/views/ethos/

Hope this helps.

Thanks, I’ve set up a child theme and made those changes.
The post slider isn’t appearing on my home page and the one that was appearing on my blog page has now lost its navigation arrows.
Edit: When I switch my custom (Pro) header off, the slider appears on my home page, but again, without navigation arrows. Unfortunately, I need to have a customised header for the site, so I need a way of having both working together!
Please can you advise.

Hi,

Please remove wp-header.php in your child theme then add the code below in your child theme’s functions.php file.


function add_slider() {
if(is_front_page()){
?>
    <div class="x-container max width"><?php x_get_view( 'ethos', '_post', 'slider' ); ?></div>
<?php
}
}

add_action( 'x_after_site_begin', 'add_slider', 10 );

Hope that helps

That’s worked, thanks.
How do I get it to appear below my custom header, rather than above it?
Also, How do I get the navigation arrows back?

Hi there,

How about just adding that as part of your header content? Example, please add this code to your child theme’s functions.php

add_shortcode('ethos_post_slider', 'ethos_post_slider');

function ethos_post_slider( $atts ) {

if( $atts['front_page'] == 'true' && !is_front_page() ) return '';

ob_start(); ?><div class="x-container max width"><?php x_get_view( 'ethos', '_post', 'slider' ); ?></div><?php 

return ob_get_clean();

}

Then add text element to your header bar (below) with this content [ethos_post_slider], and if you wish to display it just in front page then, should be like this [ethos_post_slider front_page="true"]

Thanks!

I’ll give that a go. Do I still need to have the amended _post-slider.php file in my child theme, or can I get rid of that if using this method?

I’ve done this now, but it’s not working.
If I add [ethos_post_slider] I get the error as attached in my secure note.
If I add [ethos_post_slider front_page=“true”] then nothing displays in the bar that I’ve added.

Please can you advise

Hi there,

You don’t need _post-slider.php from your child theme anymore. And that’s not an error message, it appears when your wp-config.php’s WP_DEBUG is set to true.

But if you wish to prevent that warning, please update that code to this

add_shortcode('ethos_post_slider', 'ethos_post_slider');

function ethos_post_slider( $atts ) {

$atts['front_page'] = $atts['front_page'] !== 'true' ? false : true;

if( $atts['front_page'] && !is_front_page() ) return '';

ob_start(); ?><div class="x-container max width"><?php x_get_view( 'ethos', '_post', 'slider' ); ?></div><?php 

return ob_get_clean();

}

Please remove your _post-slider.php first before we continue, the code picked up that template.

Thanks!

Have removed the _post-slider.php from my child theme and updated the functions.php with the new code, but it’s still not displaying.

Hi there,

Would you mind providing your FTP login credentials as well? The code works, I tried different variants of it. The issue is that, post slider is only applicable for blog page and archive pages. Hence, you really need a separate post slider code.

Example,

add_shortcode('ethos_post_slider', 'ethos_post_slider');

function ethos_post_slider( $atts ) {

ob_start(); ?><div class="x-container max width">

<?php

// =============================================================================
// VIEWS/ETHOS/_POST-SLIDER.PHP
// -----------------------------------------------------------------------------
// Outputs the post slider that appears at the top of the blog.
// =============================================================================

$is_blog    = true;
$is_archive = false;

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]
      );
      break;
    case 'random' :
      $args = array(
        'post_type'      => 'post',
        'posts_per_page' => $count,
        'orderby'        => 'rand',
        $info[1]         => $info[2]
      );
      break;
    case 'featured' :
      $args = array(
        'post_type'      => 'post',
        'posts_per_page' => $count,
        'orderby'        => 'date',
        'meta_key'       => $info[3],
        'meta_value'     => 'on',
        'ignore_sticky_posts'	=> true
      );
      break;
  }

  ?>

  <?php if ( $is_enabled ) : ?>

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

        <?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-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>
                    </div>
                  </div>
                </a>
              </article>
            </li>

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

        <?php wp_reset_query(); ?>

      </ul>
    </div>

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

  <?php endif; ?>

<?php endif; ?>
</div><?php 

return ob_get_clean();

}

Thanks!

Thanks. Where in my child theme would I need to put this code?

FTP details attached on secure note

Hi,

Thank you for providing your sftp login.

I went ahead and added the code that my colleague provided.

The slider is now showing up ni your front page, kindly check in your end.

Thanks

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