Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1099775
    james w
    Participant

    Right now the post-meta displays like this
    (Below the blog post title)

    Tharindu pramuditha / july 23, 2016 / categories / 0 comments
    I want to display it in following format

    Tharindu pramuditha / july 23, 2016 (One day ago) / categories / 0 comments

    I realized that I’ve required to paste following code somewhere in one of the php or function file that handles the post-meta data in child theme.

    <?php echo human_time_diff(get_the_time(‘U’), current_time(‘timestamp’)) . ‘ ago’;?>

    So, please tell me where do I paste?

    #1099789
    Christopher
    Moderator

    Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    #1100354
    james w
    Participant

    Hello, I was able to take care of it and the code looks like this

    // Time format in p-meta
    if ( ! function_exists( 'x_integrity_entry_meta' ) ) :
      function x_integrity_entry_meta() {
    
        //
        // Author.
        //
    
        $author = sprintf( '<span>Written By <a href="<?php echo "#" ?>%s</a></span>',
          get_the_author()
        );
    
        //
        // Date.
        //
    
        $date = sprintf( '<span><time class="entry-date" datetime="%1$s"> %2$s (%3$s Ago)</time></span>',
          esc_attr( get_the_date( 'c' ) ),
          esc_html( get_the_date() ),
          esc_html( human_time_diff(get_the_time('U'), current_time('timestamp')) )
        );
    
        
    
        //
        // 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%4$s</p>',
            $author,
            $date,
            $categories_list,
            $comments
          );
        }
    
      }
    endif;

    Can you please let me know if this code is alright making sure nothing harms the core files of the theme.
    Thanks, I’m also attaching the final output

    #1100445
    Rue Nel
    Moderator

    Hello There,

    Thanks for the updates! What you are trying to accomplish requires a template customization, we would like 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 your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    After the child theme is set up, please add the following code in your child theme’s functions.php file, you can insert that code in your child theme’s functions.php file. I could not be sure which stack you are using. If you are using Integrity stack then you are on the right track.

    Hope this helps.

    #1100464
    james w
    Participant

    Yes I’m on the Integrity stack and I manage child theme’s functions.php to add custom codes. Thanks for the support

    #1100470
    Rue Nel
    Moderator

    You’re welcome! We’re happy to help you out.
    If you need anything else we can help you with, don’t hesitate to open another thread.

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