WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Simple the_content hook renders first (5 posts)

  1. StormStress
    Member
    Posted 1 year ago #

    Hello,

    I'm looking to add in an authors description at the end of a post, I will be using a related post plugin later that hooks into the_content, and I want the description to be after the post but before the related posts.

    I have this so far;

    add_action ( 'the_content', 'authbio', 99 );
    
    function authbio($content)  {
        $output = the_author_meta('description');
        $content .= $output;
        return $content;
    }

    the description is rendering, but for some reason it's rendering before the post.

    Any ideas?

    Many thanks!

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    http://codex.wordpress.org/Function_Reference/the_author_meta

    NOTE: Use get_the_author_meta() if you need to return (not display) the information.

  3. StormStress
    Member
    Posted 1 year ago #

    Thanks for the reply.
    I am looking to display the_author_meta, but is it possible to have it display at the end of 'the_content' using hooks?

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    Try it with add_filter and get_the_author_meta():

    add_filter( 'the_content', 'authbio', 99 );
    function authbio($content)  {
        $output = get_the_author_meta('description');
        $content .= $output;
        return $content;
    }
  5. StormStress
    Member
    Posted 1 year ago #

    Ah, that makes sense, and works. Thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Topic