- This topic has 7 replies, 2 voices, and was last updated 5 years, 8 months ago by Leo.
-
AuthorPosts
-
August 22, 2018 at 1:53 am #656536Sam
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!
August 22, 2018 at 9:45 am #657003LeoStaffCustomer SupportHi 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/
August 22, 2018 at 8:38 pm #657404SamHi 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!
August 23, 2018 at 9:11 am #658049LeoStaffCustomer SupportHave you installed FontAwesome and picked an icon yet?
https://docs.generatepress.com/article/font-awesome/August 23, 2018 at 10:19 am #658123SamHello 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!
August 23, 2018 at 7:30 pm #658490LeoStaffCustomer SupportTry the edited code above:
https://generatepress.com/forums/topic/different-entry-metas-for-blog-post-and-archive-page/#post-657003Should be everything without the icon.
August 23, 2018 at 8:42 pm #658526SamHi Leo!
Thank you so much! I got it fixed! You rock ๐
August 24, 2018 at 9:01 am #659001LeoStaffCustomer SupportNo problem ๐
-
AuthorPosts
- You must be logged in to reply to this topic.