![]()
Acest filtru returnează codul HTML care afișează autorul postării împreună cu postările de blog.
Puteți folosi acest filtru generate_post_author_output pentru a suprascrie complet codul HTML dat, sau chiar pentru a adăuga la acesta.
Adăugați o Pictogramă
De exemplu, dacă doriți să adăugați o pictogramă de autor înaintea numelui de autor, puteți face acest lucru:
add_filter( 'generate_post_author_output', function( $output ) {
return '<i class="fa fa-user-circle" aria-hidden="true"></i> ' . $output;
} );Eliminați din Tipul Postării
Un alt exemplu este dacă doriți să eliminați autorul unui anumit tip de postare, dar vreți să-l păstrați în altă parte:
add_filter( 'generate_post_author_output', function( $output ) {
// If we're on our "my-post-type" post type, remove the author.
if ( is_post_type_archive( 'my-post-type' ) || 'my-post-type' == get_post_type() ) {
return '';
}
// Otherwise, display it.
return $output;
} );Nume Personalizat al Autorului
Încă un exemplu este dacă doriți să vă personalizați complet numele și linkul autorului:
add_filter( 'generate_post_author_output', function( $output ) {
return '<a href="MY CUSTOM URL">My Name</a>';
} );Eliminați Link-ul
În cele din urmă, dacă doriți să eliminați linkul de la autor:
add_filter( 'generate_post_author_output', function() {
printf( ' <span class="byline">%1$s</span>',
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <span class="fn n author-name" itemprop="name">%4$s</span></span>',
__( 'by','generatepress'),
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() )
)
);
} );



