Tagged: ALB, author name, shortcode
-
AuthorPosts
-
December 10, 2019 at 9:09 am #1164340
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!December 10, 2019 at 2:09 pm #1164406Hey,
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,
YigitDecember 11, 2019 at 3:27 am #1164697Thanks 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.
-
This reply was modified 5 years, 10 months ago by
adapt.
December 11, 2019 at 2:57 pm #1164832Hi,
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,
YigitDecember 11, 2019 at 10:17 pm #1165007Ahhh, that solved it. Thanks Yigit, much appreciated!
December 12, 2019 at 7:28 am #1165099Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
This reply was modified 5 years, 10 months ago by
-
AuthorPosts
- The topic ‘Shortcode to add author name to post in ALB’ is closed to new replies.
