Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #724512

    Tracy
    Participant

    I am using this code to hide the category and author on post pages:

    .p-meta span:first-of-type {display: none;}

    It works well on the post pages but it doesn’t hide the categories in the blog carousel. Is there a way to do that? Ideally I would like to hide the entire metadata line on the slider (cat and date) but not hide the date on the posts. I tried using this custom css but it did not work:

    /* Hide Author and Date */
    .x-post-carousel-meta span.entry-cover-author,
    .x-post-carousel-meta span.entry-cover-date,
    .x-post-carousel-meta span.entry-cover-categories:before {
    display: none !important;
    }

    #724523

    Thai
    Moderator

    Hi There,

    This CSS is working fine on my end:

    .x-post-carousel-meta span.entry-cover-author,
    .x-post-carousel-meta span.entry-cover-date,
    .x-post-carousel-meta span.entry-cover-categories:before {
        display: none !important;
    }

    Could you please send us with your website URL so we can take a closer look?

    Many thanks.

    #729126

    Tracy
    Participant
    This reply has been marked as private.
    #729216

    Rad
    Moderator

    Hi there,

    Thanks, but, where should I check your carousel? I can’t find it anywhere or should I activate it?

    Thanks!

    #729247

    Tracy
    Participant

    Click on “The Blog” on the main menu bar.

    #729262

    Christopher
    Moderator

    Hi there,

    You’re referring to ‘post slider’ not ‘post carousel’.

    Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    Copy _post-slider.php from framework/views/ethos and put it in the same path inside child theme, replace existing code with following :

    
    <?php
    
    // =============================================================================
    // VIEWS/ETHOS/_POST-SLIDER.PHP
    // -----------------------------------------------------------------------------
    // 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]
          );
          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'
          );
          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 id="post-<?php the_ID(); ?>" <?php post_class( 'x-post-slider-entry' ); ?> style="<?php echo x_ethos_entry_cover_background_image_style(); ?>">
                    <a>">
                      <div class="cover">
                        <div class="middle">
                          <span class="featured-meta"><?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=""></i>',
              nextText     : '<i class="x-icon-chevron-right" data-x-icon=""></i>',
              animation    : 'fade',
              smoothHeight : true,
              slideshow    : true
            });
          });
        </script>
    
      <?php endif; ?>
    
    <?php endif; ?>

    Hope that helps.

    #729269

    Tracy
    Participant

    thanks! I will give this a try.

    #729271

    Christopher
    Moderator

    You’re welcome.

    #729801

    Tracy
    Participant

    Thanks. This did get rid of the category in the post slider.

    But it may have caused two other issues:

    1. The View Post button in the post slider no longer works.

    2. The Category is still showing in the Index Featured Post Layout (see image)

    #730011

    Rad
    Moderator

    Hi there,

    1. Please update your code to this,

    <?php
    
    // =============================================================================
    // VIEWS/ETHOS/_POST-SLIDER.PHP
    // -----------------------------------------------------------------------------
    // 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]
          );
          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'
          );
          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 id="post-<?php the_ID(); ?>" <?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 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=""></i>',
              nextText     : '<i class="x-icon-chevron-right" data-x-icon=""></i>',
              animation    : 'fade',
              smoothHeight : true,
              slideshow    : true
            });
          });
        </script>
    
      <?php endif; ?>
    
    <?php endif; ?>

    2. Copy _index-featured.php from framework/views/ethos and put it in the same path inside child theme, replace existing code with following:

    <?php
    
    // =============================================================================
    // VIEWS/ETHOS/_INDEX-FEATURED.PHP
    // -----------------------------------------------------------------------------
    // Featured content output for the index pages.
    // =============================================================================
    
    $index_layout           = get_post_meta( get_the_ID(), '_x_ethos_index_featured_post_layout',  true );
    $class                  = ( $index_layout == 'on' ) ? 'featured' : '';
    $background_image_style = x_ethos_entry_cover_background_image_style();
    $categories             = x_ethos_post_categories();
    
    ?>
    
    <a href="<?php the_permalink(); ?>" class="entry-thumb <?php echo $class; ?>" style="<?php echo $background_image_style; ?>">
      <?php if ( $index_layout == 'on' && ! is_single() ) : ?>  
        <span class="featured-meta"><?php echo get_the_date( 'F j, Y' ); ?></span>
        <h2 class="h-featured"><span><?php the_title(); ?></span></h2>
        <span class="featured-view"><?php _e( 'View Post', '__x__' ); ?></span>
      <?php else : ?>
        <span class="view"><?php _e( 'View Post', '__x__' ); ?></span>
      <?php endif; ?>
    </a>

    Hope this helps.

    #730158

    Tracy
    Participant

    Thanks. Workes great

    #730174

    Nico
    Moderator

    Happy to hear that.

    Feel free to ask us again.

    Have a great day! 🙂