[Support request] Customise

Home Forums Support [Support request] Customise

Home Forums Support Customise

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1053351
    An Nguyen

    Hi Team,

    I want to customise meta data after title in blog page following this style : “by {image-avatar} {author-name}, {date publish}, {how long post’s publish}”

    {how long post’s publish}: Ex: 1min, 1hour, 1month ago, 1year ago.

    Thanks Team in advance.

    #1053401
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    So are we basically keeping the same layout you currently have, but replacing the “time to read” to “how long its been published”?

    #1053403
    An Nguyen

    Hi Tom,

    It’s right! In {date publish}, can we remove {year}?

    Thanks Tom.

    #1054056
    David
    Staff
    Customer Support

    Hi there,

    removing the Year from the Post date is a WP thing and can be changed in Dashboard > Settings > General.

    You can try this snippet from my own personal collection to generate the Posted since time:

    function db_posted_since_time() {
        ob_start();
        global $post;
        $date = $post->post_date;
        $time = get_post_time('G', true, $post);
        $mytime = time() - $time;
        if($mytime > 0 && $mytime < 7*24*60*60)
          $mytimestamp = sprintf(__('%s ago'), human_time_diff($time));
        else
          $mytimestamp = date(get_option('date_format'), strtotime($date));
        echo $mytimestamp;
        return ob_get_clean();
    }
    
    add_shortcode( 'posted-since','db_posted_since_time' );

    It creates a [posted-since] shortocde

    Can i ask that you review our support forum guidelines when you next raise a support topic. The majority of what you’re requesting is custom development. And although we try to assist all users wherever we can we have limited resources to apply what should be paid development.

    #1054162
    An Nguyen

    Hi David,

    I’m sure that I tried on my best for searching resources however, I got wrong format of meta data from this forum. It also changes my current layout. Actually, I don’t want us take more time to debug unexpected errors rather than I ask a support topic and solving by your professional skills. Both of us can save time.

    I always tried to use GP’s forum & guidelines first before asking a request. An example is that my current website is a result of combining different parts from guidelines and forum. Totally, it’s not 100% of getting them from my support topics.

    I know you have limited resources. In case, if my request in the same with previous one you can show me link. I can try following this link. Sometimes, I missed them because GP’s resources is so big and GP’s version is updated by time. I’m not sure it’s relevant to my case or out of date.

    Thanks for your kind support. I appreciate about it.

    If my request is out of GP’s support, please let me know!

    Update: Your code doesn’t work. It shows the same published date.

    #1054396
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    How are you currently customizing your post meta area? Can you share the code?

    Let me know 🙂

    #1054410
    An Nguyen

    This is this code:

    add_filter( 'generate_post_author', '__return_false' );
    add_filter( 'generate_show_comments', '__return_false' );
    add_filter( 'generate_post_date_output', 'tu_fancy_byline_readtime_social_applaud');
    		   
    function tu_fancy_byline_readtime_social_applaud( $date ) {
    	
    	printf( ' <span class="byline">%1$s</span>',
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
    			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    			esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
    			esc_html( get_the_author() ),
    			get_avatar( get_the_author_meta( 'ID' ) )
    				
    		)
    	);	
    	
    	echo $date;		
    	echo  '<span class="posted-since"> ' . do_shortcode('[posted-since]') . '</span>';
    	echo  '<span class="read-time"> ' . do_shortcode('[reading_time]') . '</span>';   // can add text after "read-time"> '
    	
    	
    }
    #1055033
    Tom
    Lead Developer
    Lead Developer

    What if you just use this?: https://wordpress.org/plugins/meks-time-ago/

    That way it will replace the current date with the time ago date.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.