• Good morning.

    Yesterday I created an author box that appears below all my posts, with my image (from Gravatar) and a short bio. I would like to include that same information in the author page, because right now the only information shown in the author page is the list of posts written by me.

    Of course, I would like to do this without having to install any extra pluggins in my site. I created the author box for my posts with a short php function added to Code Snippets, then called in the WordPress hook ‘comment_form_before’. So, I would like to call this same function from the corresponding hook in the author page, so that the bio appears just above the list of posts. But the thing is I can’t find which hook to use…

    I am using Astra theme, and I have seen this in other blogs that are using Astra. I think this shouldn’t be so difficult, but it is driving me crazy.

    If anyone there could help, I would be so grateful.

    Thanks in advance.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    The solution you seek is somewhat theme dependent, but you might try “loop_start”.

    Another approach would be to modify the author.php template (or create one if one does not exist) and insert PHP code to fetch and output the bio where you would like it. Customized templates are best kept in a child theme you would create.

    Thread Starter leticia34

    (@leticia34)

    I have been reading about loop_start but, to be honest, I don’t understand how can I apply it to this issue…

    Moderator bcworkz

    (@bcworkz)

    Use this code as a preliminary test for feasibility:

    add_action('loop_start', 'inject_content');
    function inject_content() {
      if ( is_author()) {
    	echo '<p>Loop has started</p>';
      }
    }

    If you see “loop has started” on an author archive page where you’d like the bio to appear, this would be a valid approach. You then need to add code to fetch the bio from where ever it’s stored and output it (and any applicable HTML) in place of “Loop has started”.

    polias021

    (@polias021)

    It’s great to hear about your efforts to enhance your author page! Integrating your author box into the author page using the Astra theme is indeed possible without additional plugins.

    Since you already have a PHP function working for your posts, you can adapt it for your author page. You’ll want to hook into astra_author_header_after to display your author box just above the list of posts. Here’s a brief guide:

    1. Locate the function: Ensure your PHP function is in your functions.php file or within Code Snippets.
    2. Modify the function: Adjust it if needed to ensure compatibility with the author page.
    3. Add the hook: Use the astra_author_header_after hook to call your function.

    Here’s a basic example of how you can do it:

    function custom_author_box() {
    // Your existing code for the author box
    echo '<div class="author-box">';
    echo get_avatar(get_the_author_meta('ID'), 96);
    echo '<p>' . get_the_author_meta('description') . '</p>';
    echo '</div>';
    }
    add_action('astra_author_header_after', 'custom_author_box');

    This should place your author box above the list of posts on your author page.

    Remember your bio should be your true representative and show some unique features to be interesting for the users. Besides the author’s bio same is the case for your social media profile’s bio. For example, I recommend using a decent style for Instagram bio that offers inspiration and looks attractive for more users engagement.

    I hope this helps! Let me know if you need any more assistance.

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.