Center headline in blog posts

Hi team,
I searched the forums and found code snippets, but nothing that really matches what I’m looking for. I want to:

a) center the headline of blog posts
b) remove all info underneath (author etc) except for category and date
c) I want to the info like this: “23/12/2018 | CATEGORY”

If you could help me out with code snippets, that would be amazing. Happy holidays!
Best from Berlin Germany,
Eric

Hi there,

Thanks for writing in.

Is it the headline of the blog page or headline of a post? Please provide your site’s URL that has this headline.

Thanks!

Hi, thanks so much for getting back at me this fast. It’s the headline of a blog post. the site is offline due to construction work atm, but I’m attaching a screenshot for you:

Hi There,

Please add the following CSS under X > Theme Options > CSS:

.single-post .entry-header {
    text-align: center;
}

Let us know how it goes!

that worked flawlessly, thank you!
could you assist me with the second part of my question as well?

b) remove all info underneath (author etc) except for category and date
c) I want to the info like this: “23/12/2018 | CATEGORY”

thanks so much! hope somebody’s bringing eggnog constantly.
Best,
Eric

Hi Eric,

Are you using the Renew stack?

Please update the previous CSS a bit:

.single-post .entry-header {
    text-align: center;
}
.p-meta>span:after {display: none;}

After that adding the following code under functions.php file locates in your child theme:

function x_renew_entry_meta() {

    //
    // Author.
    //

    $author = sprintf( '<span>%s</span>',
      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('d/m/Y') )
    );


    //
    // Categories.
    //

    if ( get_post_type() == 'x-portfolio' ) {
      if ( has_term( '', 'portfolio-category', NULL ) ) {
        $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
        $separator         = ', ';
        $categories_output = '';
        foreach ( $categories as $category ) {
          $categories_output .= '<a href="'
                              . get_term_link( $category->slug, 'portfolio-category' )
                              . '" title="'
                              . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                              . '"> '
                              . $category->name
                              . '</a>'
                              . $separator;
        }

        $categories_list = sprintf( '<span>%s</span>',
          trim( $categories_output, $separator )
        );
      } else {
        $categories_list = '';
      }
    } else {
      $categories        = get_the_category();
      $separator         = ', ';
      $categories_output = '';
      foreach ( $categories as $category ) {
        $categories_output .= '<a href="'
                            . get_category_link( $category->term_id )
                            . '" title="'
                            . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                            . '">'
                            . $category->name
                            . '</a>'
                            . $separator;
      }

      $categories_list = sprintf( '<span>%s</span>',
        trim( $categories_output, $separator )
      );
    }


    //
    // Comments link.
    //

    if ( comments_open() ) {

      $title  = apply_filters( 'x_entry_meta_comments_title', get_the_title() );
      $link   = apply_filters( 'x_entry_meta_comments_link', get_comments_link() );
      $number = apply_filters( 'x_entry_meta_comments_number', get_comments_number() );


	  $text = ( 0 == $number ) ? __( 'Leave a Comment', '__x__' ) : sprintf( _n( '%s Comment', '%s Comments', $number, '__x__' ), $number );


	  $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>',
        esc_url( $link ),
        esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
        $text
      );

    } else {

      $comments = '';

    }


    //
    // Output.
    //

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

}

Hope it helps :slight_smile:

all done, thank you so much!

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.