Hi I want to display the author name below the content using ALB. Is there any function I can add to the child theme? I have found some posts suggesting a short code. But this isn’t working and I don’t want to edit all posts to insert short codes manually. Thanks for any infos on how to display the author meta using the advanced layout builder.
Hey bluecafe,
I would suggest using shortcode also since you will really need it to manually insert into pages or posts even via ALB, but I think we add it via hook/filter to add it automatically after the content of posts, would you prefer to this option?
Best regards,
Nikko
Hi Nikko, thanks for your reply. A hook would be much appreciated since I have more than hundred posts and it would be a pain to insert shortcodes manually. I think the author name should be something that can be added automatically. Is there a hook I could already use?
Hi,
There’s a filter which we can use, try adding this php code at the bottom of your functions.php:
add_filter('avf_template_builder_content', 'av_add_author', 20, 1);
function av_add_author($content) {
if( is_single() ) {
$author = "<p class='alb-author'>By: <span class='entry-author-link'><span class='vcard author'><span class='fn'><a href='" . get_the_author_link() . "' title='Posts by " .get_the_author() . "' rel='author'>" .get_the_author() . "</a></span></span></span></p>";
$content = $content . $author;
}
return $content;
}
Hope it helps :)
Best regards,
Nikko
Thank you, Nikko, this works. The author appears below the comments. While this is better than nothing it would be cool if I could move the author name below the content before the comments start. Are there some more filters available? Thanks so much …
P.S.: Found it … I changed the priority to 8 … now everything is perfect! Thank you, thank you, thank you !!!! :-)
Hi,
Glad that you figured it out and it’s a pleasure to help you :) Thanks also for using Enfold and have a great day! :)
Best regards,
Nikko