- This topic has 14 replies, 6 voices, and was last updated 4 years, 4 months ago by David.
-
AuthorPosts
-
December 1, 2019 at 2:15 pm #1088493Oleksiy
Hi, guys. Could you please help me with the following issue. Task is to move the date to the bottom and remove the link.
First I’ve added this code to remove the link for the date when it was at the top (by default) – https://gist.github.com/generatepress/429d8f954419921f564f. It worked.
But then I moved date to the bottom. Used this code https://gist.github.com/generatepress/cf95fae85d5e7773d97a from this topic – https://generatepress.com/forums/topic/move-author-date-to-the-bottom-after-content/. The link for the date appeared again.
Code is added in the functions.php in the child theme. First – “moving to the bottom” code, followed by “link removal”. The date disappears from the top even without using .css code:
.entry-header .entry-meta {
display: none;
}How can I remove the link?
December 1, 2019 at 4:17 pm #1088599LeoStaffCustomer SupportHi there,
You can actually use this filter to move the date link now:
https://docs.generatepress.com/article/generate_footer_entry_meta_items/Then this snippet should remove the link:
https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-dateAdding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps 🙂
December 2, 2019 at 4:06 am #1089304OleksiyThanks a lot, Leo. It works, and with a much more compact piece of code 🙂
Is there also such compact solution to remove a link for the date in comments? I used this one – https://gist.github.com/generatepress/21b8e4b706caf59470b7. It works correctly, but I feel like it can be a shorter solution.
Also there is a question about date text. I’ve used “before” and “after” in the CSS to display “Published” and “Last updated”:
.posted-on .updated {
display: inline-block;
}.posted-on .updated:before {
content: “Last updated: ”
}.posted-on .updated:after {
content: ” |”
}.posted-on .published:before {
content: ” Published: ”
}But in this case words “Published” and “Last updated” are absent in the HTML source code. It means that they are invisible for search engines. That’s not great. How can I display them in the other way, to make them present in the source code?
December 2, 2019 at 7:08 am #1089778DavidStaffCustomer SupportHi there,
there isn’t a filter for changing the comment date link so unfortunately that solution is the way to go.
This is the HTML for your date time elements:
<time class="entry-date published" datetime="2019-11-23T18:30:53+02:00" itemprop="datePublished">23.11.2019</time>
The
itemprop="datePublished"
schema markup will be recognised by search engines.December 2, 2019 at 8:21 am #1089931OleksiyOk. Thanks, David.
December 2, 2019 at 8:56 am #1090014DavidStaffCustomer SupportYou’re welcome
December 8, 2019 at 4:31 am #1097654Haider AliHello @Leo
The date link does not remove for Example 2 listed here:
https://docs.generatepress.com/article/entry-meta-style/Please help.
Hi there,
You can actually use this filter to move the date link now:
https://docs.generatepress.com/article/generate_footer_entry_meta_items/Then this snippet should remove the link:
https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-dateAdding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps 🙂
December 8, 2019 at 10:15 am #1097960TomLead DeveloperLead DeveloperIn Example 2, find this:
<a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a>
And replace it with this:
<span class="author-name" itemprop="name">%3$s</span>
December 8, 2019 at 11:05 am #1097986Haider AliThanks for your reply Tom.
However, this removed the link from the Author name and not the date.
December 8, 2019 at 3:28 pm #1098139TomLead DeveloperLead DeveloperAh, sorry. In that case, this would be your code:
add_filter( 'generate_post_author', '__return_false' ); add_filter( 'generate_post_date_output', function( $date, $time_string ) { printf( '<span class="meta-gravatar">%s</span>', get_avatar( get_the_author_meta( 'ID' ) ) ); echo '<span class="meta-data">'; printf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><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() ) ) ); printf( // WPCS: XSS ok, sanitization ok. '<span class="posted-on">%1$s%4$s</span> ', apply_filters( 'generate_inside_post_meta_item_output', '', 'date' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), $time_string ); echo '</span>'; }, 10, 2 );
December 9, 2019 at 2:02 am #1098375Haider AliIt worked! Thank you so much Tom
December 9, 2019 at 3:38 am #1098450AlexHi! Thanks for your great support here. I’ve also tried to apply this code
add_filter( ‘generate_post_date_output’, function( $output, $time_string ) {printf( ‘<span class=”posted-on”>%s</span>’, $time_string);}, 10, 2 );
It works OK, but the date and “by” are put together and the entry meta reads like this:
July 9, 2019by Author. Is there a way to separate them?
Thanks for your reply!December 9, 2019 at 5:50 am #1098538DavidStaffCustomer SupportHi there,
try inserting a space after the
s
in this code:<span class=”posted-on”>%s</span>
ie.
<span class=”posted-on”>%s </span>
December 10, 2019 at 12:20 am #1099510AlexThank you! So easy 🙂
December 10, 2019 at 4:38 am #1099678DavidStaffCustomer SupportGlad to be of help
-
AuthorPosts
- You must be logged in to reply to this topic.