- This topic has 7 replies, 2 voices, and was last updated 2 years, 11 months ago by
Tom.
-
AuthorPosts
-
February 22, 2020 at 4:29 am #1173433
Scott
I am using the following function from the forum to style my article meta as a snippet:
add_filter( 'generate_post_author_output', function() { return sprintf( ' <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( __( 'Learn more about %s', 'generatepress' ), get_the_author() ) ), esc_html( get_the_author() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); } ); add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'comments-link', 'date', 'tags', ); } );
with the following CSS (also from the forum):
/*postmeta*/ .posted-on .updated { display: inline-block; } .posted-on .updated + .entry-date { display: none; } .posted-on .updated:before { content: "Last Updated: "; } .byline img { width: 25px; height: 25px; border-radius: 50%; position: relative; vertical-align: middle; margin: 0 10px 0 0; } .comments-link, .posted-on { padding-left: 10px; margin-left: 10px; } .tags-links { padding-left: 10px; margin-left: 10px; }
I moved my article title and meta into a page hero (using the template tags) so that I could have that section full-width. Now, I have lost the formatting. I tried adding .page-hero to the CSS and that didn’t work. Is there a modification to the snippet I need to make to re-establish that format?
Thanks!
ScottFebruary 22, 2020 at 10:31 am #1173792Tom
Lead DeveloperLead DeveloperThe Page Hero meta has different filters/CSS. What exactly are you wanting to do? I should be able to help with the code.
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 22, 2020 at 11:35 am #1173827Scott
Thanks Tom! You guys always go above and beyond!
What I have there is pretty close to what I had before, just two changes:
1. My photo to the left of my name (from WordPress user profile)
2. Date changed to “Updated on: XXXX XX, XXXX” with the modified date instead of the posted date (no archive links).THANKS!!
February 22, 2020 at 4:04 pm #1173941Tom
Lead DeveloperLead DeveloperCheck out example #2 here to add your gravatar: https://docs.generatepress.com/article/page-hero-examples/#example-2
As for the date, try this:
add_filter( 'generate_page_hero_post_date', function() { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = 'Updated on: <time class="updated-date" datetime="%3$s" itemprop="dateModified">%4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); return $time_string; } );
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 23, 2020 at 3:32 am #1174186Scott
Hey Tom –
Added the code and the “Updated on:” is there but there is no date showing at all after it.
THANKS!
February 23, 2020 at 9:46 am #1174534Tom
Lead DeveloperLead DeveloperCan you try the updated function?: https://generatepress.com/forums/topic/article-meta-in-page-hero/#post-1173941
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 23, 2020 at 12:08 pm #1174615Scott
That did it! Thanks so much!
February 23, 2020 at 6:05 pm #1174768Tom
Lead DeveloperLead DeveloperNo problem! π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.