• Resolved Jim

    (@smokingblends)


    Hello,

    We have been attempting to use the instructions to add an author box without plugin via our child theme. The instructions seem to be wrong and it does not work. Instructions – (“You’ll need to add the code below the “the_content()” function and above the main div container:” ) There is no “the_content()” function on the single.php page.

    Any help would be appreciated.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there @smokingblends ??

    Adding author box without plugin.

    With a web search, I was able to find the article linked here, for adding author boxes in various ways.

    I trust that points you in the right direction, but if you have more questions, let us know.

    We’re happy to help.

    Thread Starter Jim

    (@smokingblends)

    @anastas10s We searched for a long time for another option. All we could find was the same code that went on the single.php page, or for plugins. The information on that page should do the trick. It has a different code that goes on a completely different page. Thanks

    Hi @smokingblends
    Unfortunately, those guides are too generic, and it depends on the theme’s implementation of templates and templates part. In this case, Storefront uses a template part to display the post, and that is the reason the_content() is not present there.

    Furthermore, editing the theme files is not a safe and future-proof option; each update would revert your changes. If you want to do many modifications, I would advise you to create a child theme. (sorry, just noticed you are already using a child theme)

    For this specific situation, the safest way would be to use the storefront_single_post_bottom action, which will get fired after the post content (just like the post nav and comments).

    I have rewriten the guide’s example to use this action instead (you can paste it at the end of your child theme functions.php file):

    add_action('storefront_single_post_bottom', function() {
    ?>
    <div class="about-author">
    <div class="about-author-image">
    <?php echo get_avatar(get_the_author_meta('ID'), 250); ?>
    </div>
    <div class="about-author-text">
    <h3>About <?php echo get_the_author_meta( 'display_name'); ?></h3>
    <?php echo wpautop(get_the_author_meta('description')); ?>
    <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>">View all posts by <?php the_author(); ?></a>
    </div>
    </div>
    <style>/* insert custom css here */</style>
    <?php
    }, 1);
    
     

    Please note, that it might need tweaking to look good. I left an indication where custom css to address styling could be added.

    Thread Starter Jim

    (@smokingblends)

    @pauloarromba Thanks, we have not gotten around to doing this yet. That does seem like the better way to go.

    @smokingblends If you need further assistance in tweaking the provided info or styling the author box, feel free to tag me here.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding author box without plugin.’ is closed to new replies.