[Resolved] Different Entry Metas For Blog Post And Archive Page

Home Forums Support [Resolved] Different Entry Metas For Blog Post And Archive Page

Home Forums Support Different Entry Metas For Blog Post And Archive Page

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #656536
    Sam

    Hi there,

    Would like to know how to create different entry metas for

    1. Blog Post (Entry Meta includes Gravatar image + Last Updated Clock Icon + Last Updated Date in the right format

    https://drive.google.com/file/d/1Mnen7qqBs3Cb5kJnaCGk_RNfAd5IPCF0/view?usp=sharing

    2. Blog Page (Entry Meta includes Gravatar image + simple text “by [author name without link to his/her archives]”

    https://drive.google.com/file/d/1Dj_5B5Vs-Boxys2o9r6aEZ0YCcfWtl3H/view?usp=sharing

    Thank you so much!

    Do include PHP and CSS in your reply, if possible. Thank you in advance!

    #657003
    Leo
    Staff
    Customer Support

    Hi there,

    Something like this should get you close:

    add_filter( 'generate_post_author', '__return_false' );
    add_filter( 'generate_show_comments', '__return_false' );
    add_filter( 'generate_post_date_output', 'tu_fancy_byline' );
    function tu_fancy_byline( $date ) {
    	printf( ' <span class="byline">%1$s</span>',
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$sby <span class="author-name" itemprop="name">%3$s</span></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;
    }

    Then this for the CSS:

    .byline img {
        width: 25px;
        height: 25px;
        border-radius: 50%;
        position: relative;
        vertical-align: middle;
        margin: 0 10px 0 0;
    }
    
    .byline,
    .comments-link,
    .posted-on {
    	display: inline-block;
    }
    
    .comments-link,
    .posted-on {
    	/*border-left: 1px solid #ddd;*/
    	padding-left: 10px;
    	/*margin-left: 10px;*/
    }
    .single .comments-link,
    .single .posted-on {
    	border-left: 1px solid #ddd;
    	padding-left: 10px;
    	margin-left: 10px;
    }
    
    .comments-link:before {
    	display: none;
    }
    
    h2.entry-title {
        margin-bottom: 20px;
    }
    
    .posted-on .updated {
        display: inline-block;
    }
    
    .posted-on .updated + .entry-date {
        display: none;
    }
    .posted-on .updated:before {
        content: "Last Updated ";
    }
    .blog .posted-on, .archive .posted-on {
        display: none;
    }

    The idea comes from this: https://docs.generatepress.com/article/entry-meta-style/

    #657404
    Sam

    Hi Leo,

    Thanks for your help! I’ve managed to get close like you said, but:

    1. On the blog archive page, there is a link to the author’s name. I would like to replace it with a simple “by Author A” without enabling a link to the author’s archives, after the Gravatar. So it should be [Gravatar image] by Author A

    2. On the blog post page, I would like the same thing, without the “|”. So the correct syntax should be:

    [Gravatar Image] by Author A [clock icon] Last updated Jul. 16, 2018

    Thank you so much for your help Leo!

    #658049
    Leo
    Staff
    Customer Support

    Have you installed FontAwesome and picked an icon yet?
    https://docs.generatepress.com/article/font-awesome/

    #658123
    Sam

    Hello Leo!

    I’ve did a check via the link you sent, and Font Awesome seems not to be supported anymore due to it being deprecated (noob me doesn’t know what that means)

    In that case, does me installing FA slow down my site?

    If so, what if I just wanted to display:

    [Gravatar Image] by Author A | Last updated Jul. 16, 2018 (no links please!)

    Thank you so much your patience!

    #658490
    Leo
    Staff
    Customer Support
    #658526
    Sam

    Hi Leo!

    Thank you so much! I got it fixed! You rock ๐Ÿ™‚

    #659001
    Leo
    Staff
    Customer Support

    No problem ๐Ÿ™‚

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