Archived topic
adjusting post meta in child theme
7 replies · Started by manaadiar on July 27, 2021
Hi there.. I am looking for an option to remove the "by" before the Author.. I would like to also bring the author icon and name to the next line below Date Posted On and above Categories..
While this is possible to change in the parent theme in Line 213 by removing %1$s and entering a <br> before the <span class="author%8$s"..............., it doesn't work in the child theme because this line of code is not there in the child theme..
$byline = '<span class="byline">%1$s<span class="author%8$s" %5$s><span class="author-name"%7$s>%4$s</span></span></span> ';
Pls let me know how this can be achieved..
Hi there,
Try this filter to remove the "by":
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() )
)
);
}
To move the author to next line, try this CSS:
.entry-meta .byline {
display: block;
}
Hi Ying, the function filter worked, but below code didn't work for creating line break..
.entry-meta .byline {
display: block;
}
So I added a <br> in the function itself as below and its working fine now.. Thanks..
//code to eliminate by in the post-meta
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( '<br><span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><span class="author-name" itemprop="name">%3$s</span></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() )
)
);
}
Hi there,
I believe this is the aim? https://share.getcloudapp.com/bLukXwqv
If so, try this CSS:
.entry-meta {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.entry-meta > span {
flex: 1 0 100%;
}
Nope, didn't work.. So reverted my solution..
have you sorted it out? It looks fine now on my end as shown here - https://share.getcloudapp.com/nOuv6g8x
Let us know if you need further help with it. :D
Hi Elvin, yes it is now sorted thanks..
Nice one! Thanks for letting us know. Glad you got it sorted. :D