Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1328055

    zendern
    Participant

    Hi!
    I am using v. 4.6.4 X Theme with activated child theme and Icon Stack.
    URL: http://happypeople.blog

    I have upgraded my old premium theme “Simple & Elegant” to Theme X and I am happy I did. Now I am trying to give my site the same look as it was with my Simple & Elegant theme.
    Old site URL: http://makoeva.net/

    I want post meta to show Date, Categories, Leave a comment, just like on http://makoeva.net/
    Font PT Sans, Font site: 12, color black.
    I also want to add a separator between post header and post meta, just like or similar to http://makoeva.net/

    I have tried following instructions on link below, buy with no success: https://community.theme.co/forums/topic/icon-stack-post-meta-author-tags-categories-not-showing-in-posts/

    Your help will be greatly appreciated.

    #1328314

    Rupok
    Member

    Hi there,

    Thanks for writing in! You can add the below code within your Child Theme’s functions.php

    // Entry Meta
    // =============================================================================
    
    if ( ! function_exists( 'x_icon_entry_meta' ) ) :
      function x_icon_entry_meta() {
    
        $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() )
        );
    
        if ( x_does_not_need_entry_meta() ) {
          return;
        } else {
          printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
            $date,
            $author,
            $categories_list
          );
        }
    
      }
    endif;

    Then you can add this under Custom > CSS in the Customizer.

    .entry-header .p-meta {
      color: #000;
      font-family: "PT Sans",sans-serif;
      font-size: 12px;
      opacity: 1;
    }

    Make sure to set PT Sans font from Customize > Typography.

    Cheers!

    #1329204

    zendern
    Participant
    This reply has been marked as private.
    #1329571

    Christopher
    Moderator

    Hi there,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thanks.

    #1334263

    zendern
    Participant
    This reply has been marked as private.
    #1334613

    Christopher
    Moderator

    Hi there,

    Please update your code in functions.php file to :

    // Entry Meta
    // =============================================================================
    
    if ( ! function_exists( 'x_icon_entry_meta' ) ) :
      function x_icon_entry_meta() {
    
     $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-clock" 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-folder" 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-folder" 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-sticky-note" 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">%2$s%3$s%4$s</p>',
            $author,
            $date,
            $categories_list,
            $comments
          );
        }
    
      }
    endif;
    
    

    Please add following code in Customize -> Custom -> Global CSS :

    p.p-meta span, p.p-meta a {
        color: #000;
        font-size: 12px;
        font-family: PT Sans-serif;
    }

    Hope it helps.

    #1335614

    zendern
    Participant

    Thank you for your code! It worked for the most part.

    The comments are not inline with date and category meta, instead, they have floated to the right side of the page in a little round bubble.

    How do I have a leave a comment link inline with date and category meta?
    I do not need this meta tag to count the amount of comments there are.
    Just a link to a comment section is best.

    Thank you again for you support!

    #1335630

    zendern
    Participant

    Another problem I noticed is font size of date and category meta tags are different.

    It stays different even if I remove custom CSS styling.

    #1336133

    Lely
    Moderator

    Hello There,

    Please add this custom CSS too:

    a.meta-comments {
        position: relative;
        width: initial;
        height: initial;
        border: transparent;
        background: transparent;
        top: initial;
        right: initial;
    }

    Then look for this line from above code:
    $text = ( 0 === $number ) ? 'Leave a Comment' : sprintf( _n( '%s Comment', '%s Comments', $number, '__x__' ), $number );
    Update to this:
    $text = ( 0 === $number ) ? 'Leave a Comment' : _n( ' Comment', ' Comments', $number, '__x__' );

    Look for this custom CSS:

    /* date color*/
    .entry-date {
        color:#00000;
    font-size: 80%;
    }

    This line font-size: 80%; makes the date font smaller. Please remove it.

    Hope this helps.

    #1337736

    zendern
    Participant

    This is great.
    Now everything is working the way we want it to.

    Thank you all for your patient, detailed and tailored support!

    #1337804

    Prasant Rai
    Moderator

    You are most welcome. πŸ™‚

    #1342536

    zendern
    Participant

    Hello again!

    With further testing I found out that the comment meta tag displays differently in some browsers.

    To achieve desired look of the comment meta tag I translated tags to Russian by editing functions.php like this:

    Original code:
    $text = ( 0 === $number ) ? 'Leave a Comment' : _n( ' Comment', ' Comments', $number, '__x__' );
    Edited as: 
    $text = ( 0 === $number ) ? 'ΠžΡΡ‚Π°Π²ΠΈΡ‚ΡŒ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ' : _n( ' ΠšΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ', ' ΠšΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΈ', $number, '__x__' );

    In some browsers life Firefox comments meta tag displays correctly in Russian, while in other browsers like Edge or iOS browser it still displays as “0 Comments” in English.

    Hope you can help.

    #1342745

    Lely
    Moderator

    Hello There,

    I did check on IE, CHROME and FIREFOX and everything says COMMENTS and not the russian translation. Please do give us admin credentials again so we can check your settings.

    #1343337

    zendern
    Participant
    This reply has been marked as private.
    #1344254

    Paul R
    Moderator

    Hi,

    I tried your code in my test site and it seems to work.

    It seems that something is overriding the code in your site.

    Can you try testing for a plugin conflict. You can do this by deactivating all third party plugins, and seeing if the problem remains. If it’s fixed, you’ll know a plugin caused the problem, and you can narrow down which one by reactivating them one at a time.

    Thanks