[Support request] post author output – change "by" by something else…

Home Forums Support post author output – change "by" by something else…

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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 – $author

    add_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.48
    GP Premium 1.3
    #335002
    Leo
    Staff
    Customer Support

    Hi there,

    A plugin like this might help: https://en-ca.wordpress.org/plugins/say-what/

    The “text domain” you need is: generatepress

    #335004
    Tom
    Lead Developer
    Lead Developer

    Hi 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/

    #335198
    éric

    hello tom, thanks a lot,
    sorry, but this code generated many errors : unexpected “)” and even one unexpected “}” …

    #335204
    Tom
    Lead Developer
    Lead Developer

    Ah, sorry about that. Adjusted the code above.

    #335207
    éric

    and it works! thanks again Tom.

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