Tagged: ALB, author name, shortcode
Hi there
Hopefully really straightforward one here.
I’d like the author name to appear on the blog post page created in ALB.
I’ve already activated the name to appear in the Enfold settings, and it’s displaying fine in the blog archive page, but as it hasn’t been set within the ALB, it’s obviously not displaying on individual blog post pages.
Any help would be greatly appreciated!
Hey,
Please add following code to bottom of Functions.php file in Appearance > Editor
function av_post_author() {
echo "<p>Written by: ". get_the_author_link() ."</p>";
}
add_shortcode( 'av_author', 'av_post_author' );
and use [av_author] shortcode :)
Best regards,
Yigit
Thanks Yigit :)
However, when I add the shortcode to a standard content block (after first editing functions.php with the script you provided), I’m getting the error:
“Updating failed. Error message: The response is not a valid JSON response”
when I try to save the post?
I tried inserting the shortcode in a Code Block element instead (rather than Text Block), and although it works, the “Written by” text simply appears at the top of the page, regardless of where I put that Code Block within the ALB.
Hi,
Please replace the code in the bottom of Functions.php file with following one
function av_post_author() {
ob_start();
echo "<p>Written by: ". get_the_author_link() ."</p>";
return ob_get_clean();
}
add_shortcode( 'av_author', 'av_post_author' );
That should fix the issue :)
Best regards,
Yigit
Ahhh, that solved it. Thanks Yigit, much appreciated!
Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon