Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1104272
    Matt Mintun
    Participant

    Hey!

    I’m wondering if it’s possible to split up Meta Info on a blog post. I’ve doven into a child theme and customized my blog layouts to get the overall look and feel I’m looking for. I’m using Ethos and now my blog post layout is:

    Post Title
    In [Category(s)] by [Author] / [Date] /# Comments
    Featured image
    Content

    What I’d like to do is split up the meta info and change the way it’s displayed to be like this:

    [Category(s)]
    Post Title
    [Date] * By [Author] * # Comments

    Is this possible? I’m not sure how to change this since the template files just show the line:

    <?php x_ethos_entry_meta(); ?>

    I’m assuming it’d be something I change in functions, but not quite sure 🙂

    Thank you!
    Matt

    #1104756
    Lely
    Moderator

    Hello Matt,

    Please try adding the following code for category on your _content-post-hheader.php file on your child theme, just above this line: <h1 class="entry-title"><?php the_title(); ?></h1>

    	<?php 
        //
        // 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>%1$s %2$s',
              __( 'In', '__x__' ),
              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>%1$s %2$s',
            __( 'In', '__x__' ),
            trim( $categories_output, $separator )
          );
        }
    
    	echo $categories_list;	
    	
    	?>

    Then to remove the categories from this function:x_ethos_entry_meta();, add the following code on your child theme’s functions.php file:

    
      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() )
        );
    
        //
        // 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>%1$s %2$s',
              __( 'In', '__x__' ),
              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>%1$s %2$s',
            __( 'In', '__x__' ),
            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' : 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%3$s</p>',
            $date,
    		$author,
            $comments
          );
        }
    
      }

    Hope this helps.

    #1108127
    Matt Mintun
    Participant
    This reply has been marked as private.
    #1108326
    Rupok
    Member

    Hi there,

    Thanks for writing back. Yes that could be possible with some custom CSS. You need to add this under ChildChild Theme‘s style.css if you want to add icon :

    .p-meta > span::after {
      content: "\f068 ";
      font-family: FontAwesome;
    }

    You will find all icons here – http://fontawesome.io/icons/

    Let’s open your preferred icon and grab the UNICODE – http://prntscr.com/byxf1p

    Hope this helps.

    #1267160
    Kev_LeM
    Participant

    I would like to do a similar modification with the integrity theme and have the order of the information be:

    [Date]
    Post Title
    By [Author]

    Is this possible with simply modifying the code from the previous answer?

    I already have a child theme installed and _CONTENT-POST-HEADER.PHP copied into child integrity folder.

    Thanks in advance.

    #1267670
    Darshana
    Moderator

    @kev_lem

    I’m not sure what you want to accomplish based on the original request. Post Title is not part of the meta information. You can copy the following function into your child theme and make your modifications.

    
    // Change Meta Info Order
      function x_integrity_entry_meta() {
    
        //
        // Author.
        //
    
        $author = sprintf( '<span><i class="x-icon-pencil" data-x-icon=""></i> %s</span>',
          get_the_author()
        );
    
        //
        // Date.
        //
    
        $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar" data-x-icon=""></i> %2$s</time></span>',
          esc_attr( get_the_date( 'c' ) ),
          esc_html( get_the_date() )
        );
    
        //
        // 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 ) )
                                  . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
                                  . $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 ) )
                                . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
                                . $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' : sprintf( _n( '%s Comment', '%s Comments', $number, '__x__' ), $number );
    
    $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments" data-x-icon=""></i> %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%3$s%4$s</p>',
            $author,
            $date,
            $categories_list,
            $comments
          );
        }
    
      }
    

    Thanks!

    #1268283
    Kev_LeM
    Participant

    Hello again, thanks, but I already have the above code.

    What I am trying to accomplish is represented in the following pictures below.

    I am having trouble putting the order of post information as

    [Date]
    Post Title
    By [Author]

    Also I would like to add the word “by” in front of author.
    I am using Integrity 1 Stack with child theme for modification.

    Thank you in advance.

    #1268352
    Rupok
    Member

    Hi there,

    Yes those are possible but as it’s custom development, we can’t assist much on such. As mentioned on the previous reply, you can modify the code to achieve what you want.

    Thanks!

    #1268394
    Kev_LeM
    Participant

    The above code doesn’t put the blog title beneath the date.

    #1268744
    Rad
    Moderator

    Hi there,

    Yes, you still need to modify the code and template to achieve what you need. It’s only provided as the reference where you can start your custom development.

    Example,

    1. Remove category, then change this code

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

    to this

    $categories_list = "";

    2. Move date above the title, then change this code

     $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() )
        );

    $date = "";

    Then add this code to your _CONTENT-POST-HEADER.PHP just above the title,

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

    3. As for the author, simply change this code

     printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
            $author,
            $date,
            $categories_list,
            $comments
          );

    to this

     printf( '<p class="p-meta">by %1$s</p>',
            $author
          );

    Then it’s up to you how you’ll implement the styling based on your mockup design. This change only modify the order of the element based from your screenshot.

    Thanks.

  • <script> jQuery(function($){ $("#no-reply-1104272 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>