- This topic has 7 replies, 3 voices, and was last updated 2 years, 8 months ago by Elvin.
-
AuthorPosts
-
July 27, 2021 at 2:33 am #1872535manaadiar
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..
July 27, 2021 at 2:55 pm #1873544YingStaffCustomer SupportHi 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; }
July 28, 2021 at 1:16 am #1873966manaadiarHi 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() )
)
);
}July 28, 2021 at 1:51 am #1874003ElvinStaffCustomer SupportHi 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%; }
July 28, 2021 at 2:16 am #1874026manaadiarNope, didn’t work.. So reverted my solution..
July 28, 2021 at 6:19 pm #1875142ElvinStaffCustomer Supporthave 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. ๐
July 28, 2021 at 11:08 pm #1875271manaadiarHi Elvin, yes it is now sorted thanks..
July 29, 2021 at 12:43 am #1875342ElvinStaffCustomer SupportNice one! Thanks for letting us know. Glad you got it sorted. ๐
-
AuthorPosts
- You must be logged in to reply to this topic.