Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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!

    #1164406

    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

    #1164697

    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.

    • This reply was modified 4 years, 3 months ago by adapt.
    #1164832

    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

    #1165007

    Ahhh, that solved it. Thanks Yigit, much appreciated!

    #1165099

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Shortcode to add author name to post in ALB’ is closed to new replies.