Only show date in post (Ethos)

I want to remove all meta in post except the date.

Hello There,

Thanks for writing in!

What you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released.

After the child theme is set up, please add the following code in your child theme’s functions.php file

if ( ! function_exists( 'x_ethos_entry_meta' ) ) :
  function x_ethos_entry_meta() {

    //
    // Author.
    //

    $author = sprintf( ' %1$s %2$s</span>',
      __( 'By', '__x__' ),
      get_the_author()
    );


    //
    // Date.
    //

    $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>',
      esc_attr( get_the_date( 'c' ) ),
      esc_html( get_the_date() )
    );

    //
    // Output.
    //

    if ( x_does_not_need_entry_meta() ) {
      return;
    } else {
      printf( '<p class="p-meta">%1$s . %2$s</p>',
        $author,
        $date
      );
    }

  }
endif;

Please let us know how it goes.

Hmmm. I still see the author and not only the date.

Hello There,

Please have it updated and use this:

if ( ! function_exists( 'x_ethos_entry_meta' ) ) :
  function x_ethos_entry_meta() {

    //
    // Date.
    //

    $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>',
      esc_attr( get_the_date( 'c' ) ),
      esc_html( get_the_date() )
    );

    //
    // Output.
    //

    if ( x_does_not_need_entry_meta() ) {
      return;
    } else {
      printf( '<p class="p-meta">%1$s</p>',
        $date
      );
    }

  }
endif;

Please let us know how it goes.

Great. Only date in post.

But: om frontpage blog the date is gone.

Hey There,

It is not displayed because you have added this custom css

.blog .p-meta span:nth-child(1), .blog .p-meta span:nth-child(2):after, .blog .p-meta span:nth-child(3) {
    display: none;
}

Please find and remove this custom css because it is no longer necessary.

Works great! Thanks.

You’re welcome!
We’re glad we were able to help you out.

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