Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #925219

    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.

    #925371

    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

    #925707

    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?

    • This reply was modified 6 years, 8 months ago by bluecafe.
    #925859

    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

    #925899

    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 !!!! :-)

    • This reply was modified 6 years, 8 months ago by bluecafe.
    #926046

    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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘How can I add the Author name below single post content using ALB?’ is closed to new replies.