Post Carousel (Ethos) Tag Display

Hi guys!

Hope everyone is doing well.

I have a question in regards to the post carousel display. The basis Ethos set-up shows:

  • Author
  • Category
  • Date

What I’d like to build is the following display:

  • Author
  • Category
  • Tag

So how can I add a “tag” meta display to the post carousel?

Also, I tried removing the date but was not successful. I used this code (last one on the screenshot below):

.x-post-carousel-meta .entry-cover-date {
display: none;
}

Did I do something wrong?

Please advise - thank you so much in advance!

P.S. We are using customized Child theme.

Daria

Hello @gsbook,

Thanks for asking. :slight_smile:

I have added following code in your theme options panel to hide Date from post carousel.

span.entry-cover-date {display: none;}

Displaying tags in post slider will fall outside the scope of support we offer as it requires custom development. But I can point you in right file that need to edited and the resources that will help you to make required changes. First, please copy ethos.php file from wp-content/themes/x/framework/functions/ethos.php to wp-content/themes/x-child/framework/functions/ethos.php. After that please refer following post that will help you to get started with Tags. If you are not comfortable with programming, I suggest you to seek professional help.

https://codex.wordpress.org/Function_Reference/the_tags

https://codex.wordpress.org/Function_Reference/get_the_tag_list

Thanks.

Thank you very much Prasant! Does Themeco offer professional help with customization by any chance? Or could you please point me in the right direction, if you can of course?

Thanks so much,

Daria

Hi There,

Basically to edit that functionality, you will need to copy the below code into your child theme’s functions php file.

function x_ethos_entry_cover( $location ) {

    if ( $location == 'main-content' ) { ?>

      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <a class="entry-cover" href="<?php the_permalink(); ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>">
          <h2 class="h-entry-cover"><span><?php x_the_alternate_title(); ?></span></h2>
        </a>
      </article>

    <?php } elseif ( $location == 'post-carousel' ) { ?>

      <?php GLOBAL $post_carousel_entry_id; ?>

      <article <?php post_class(); ?>>
        <a class="entry-cover" href="<?php the_permalink(); ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>">
          <h2 class="h-entry-cover"><span><?php ( $post_carousel_entry_id == get_the_ID() ) ? the_title() : x_the_alternate_title(); ?></span></h2>
          <div class="x-post-carousel-meta">
            <span class="entry-cover-author"><?php echo get_the_author(); ?></span>
            <span class="entry-cover-categories"><?php echo x_ethos_post_categories(); ?></span>
            <span class="entry-cover-date"><?php echo get_the_date( 'F j, Y' ); ?></span>
          </div>
        </a>
      </article>

    <?php }

  }

Then locate the following line where date displayed.
<span class="entry-cover-date"><?php echo get_the_date( 'F j, Y' ); ?></span>

Now you can edit that line with your custom code with the help of the above references.

Hope that helps.

Thank you so much!!

I followed all the directions above and found the exact line:
<?php echo get_the_date( 'F j, Y' ); ?>

I replaced it with: <span class="entry-cover-the-tags”><?php echo x_ethos_post_the_tags(); ?>

But nothing really changes on the front end unfortunately.

Hi,

It’s because you have the following code that hides the date.

span.entry-cover-date {
    display: none;
}

Kindly remove it in Theme Optins > CSS the add the code provided by my colleague in your child theme’s functions.php file.

Thanks

Thank you very much! I deleted the code from CSS, and then added the given code to my functions.php file however the “date” field is still there and it didn’t get replaces with “tags”.

I also tried replacing the line as mentioned above with the following code (attached below)

But it crashed the website so I had to remove it. If someone could please give me the right code to replace the “date” meta field with “tags” in post carousel - I would be enormously grateful. I’m attaching a screenshot of the current code below.

Again - thanks a mill in advance!

replaced line:

<span class="entry-cover-the-tags”><?php echo x_ethos_post_the_tags(); ?>

Hi,

Please change code to this.

 function x_ethos_entry_cover( $location ) {
   $posttags = get_the_tags();
   $my_tags = array();
   if ($posttags) {
      foreach($posttags as $tag) {
        $my_tags[] = $tag->name; 
      }
   }
    if ( $location == 'main-content' ) { ?>

      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <a class="entry-cover" href="<?php the_permalink(); ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>">
          <h2 class="h-entry-cover"><span><?php x_the_alternate_title(); ?></span></h2>
        </a>
      </article>

    <?php } elseif ( $location == 'post-carousel' ) { ?>

      <?php GLOBAL $post_carousel_entry_id; ?>

      <article <?php post_class(); ?>>
        <a class="entry-cover" href="<?php the_permalink(); ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>">
          <h2 class="h-entry-cover"><span><?php ( $post_carousel_entry_id == get_the_ID() ) ? the_title() : x_the_alternate_title(); ?></span></h2>
          <div class="x-post-carousel-meta">
            <span class="entry-cover-author"><?php echo get_the_author(); ?></span>
            <span class="entry-cover-categories"><?php echo x_ethos_post_categories(); ?></span>
            <span class="entry-cover-date"><?php echo implode(", ",$my_tags); ?></span>
          </div>
        </a>
      </article>

    <?php }
  }

Hope that helps.

Paul,

It worked! THANK you SO MUCH! You guys are simply the BEST! I truly mean it!!!

You’re most welcome. We’re happy to help. :slight_smile:

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