- This topic has 5 replies, 3 voices, and was last updated 3 years, 9 months ago by
éric.
-
AuthorPosts
-
June 17, 2017 at 9:38 am #334994
éric
Hello,
I understand that if I want to change the text before the author, within the blog, I have to use a filter. But where do add this filter? In a function file? (I’m having a child theme, but not really using it, acutally not using it at all) or Using Code Snippets like in https://docs.generatepress.com/article/adding-php/ ?
Besides, I really don’t know how to write this :
Instead of having $date par $author
I wish to have $date – $authoradd_filter( ‘generate_post_author_output’,’vero_no_by_to_post_author’ );
function vero_no_by_to_post_author ( $output ) {
return ‘<i class=”fa fa-user-circle” aria-hidden=”true”></i> ‘ . $output;
}( by the way, in French, “Par” would be better than “de” – maybe I should just change this )
Thanks in advance for your help ,
Véronique
GeneratePress 1.3.48GP Premium 1.3June 17, 2017 at 9:43 am #335002Leo
StaffCustomer SupportHi there,
A plugin like this might help: https://en-ca.wordpress.org/plugins/say-what/
The “text domain” you need is: generatepress
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 17, 2017 at 9:46 am #335004Tom
Lead DeveloperLead DeveloperHi there,
Try this if you don’t want to use a plugin:
add_filter( 'generate_post_author_output', 'tu_change_author_by_text' ); function tu_change_author_by_text() { printf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">- <a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url"><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() ) ) ); }
You can add it like this: https://docs.generatepress.com/article/adding-php/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 17, 2017 at 11:14 pm #335198éric
hello tom, thanks a lot,
sorry, but this code generated many errors : unexpected “)” and even one unexpected “}” …June 17, 2017 at 11:32 pm #335204Tom
Lead DeveloperLead DeveloperAh, sorry about that. Adjusted the code above.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 17, 2017 at 11:34 pm #335207éric
and it works! thanks again Tom.
-
AuthorPosts
- You must be logged in to reply to this topic.