WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Use Author_the_description outside of the loop (8 posts)

  1. Mischif
    Member
    Posted 7 years ago #

    On my theme, I want the author's "about yourself" to show up in a sidebar that is not in the loop, but the codex says that's not possible, but is there any way to do it, or use another tag to do the same thing?

  2. Sivar
    Member
    Posted 7 years ago #

    Link and a more detailed explanation of where (and on what page) you want to put the author description, plz...

  3. Mischif
    Member
    Posted 7 years ago #

    OK, on my site at mischif.nfshost.com, you see the little blurb about myself on the sidebar on the left? I had to type that in manually, and if I release the theme, anyone who wants to use it will have to too; but I want to put a tag where the words are that will display the "about yourself" they put in their profile on the page, instead of having them type it in manually.

    PS that sidebar is on a separate page called profile.php

  4. Sivar
    Member
    Posted 7 years ago #

    Well, if you want to use it on a profile page, just put the_author_description() outside of the loop. May not be very nice, but should work.

    If it doesn't work, try "wrapping" it with

    <?php if (have_posts() : the_post();
    the_author_description();
    endif;
    rewind_posts(); ?>

    Don't use while (have_posts()), otherwise you'd get as many author descriptions as posts are being queried ;). But it's still a little dirty, I think... maybe someone else has a better way to offer.

  5. Mischif
    Member
    Posted 7 years ago #

    When I try that, it gives me an error:

    Parse error: syntax error, unexpected ':' in /nfsn/content/mischif/public/wordpress/wp-content/themes/MB1/profile.php on line 35

  6. Sivar
    Member
    Posted 7 years ago #

    Yeah, my mistake ;)... how about this:

    <?php if (have_posts()) : the_post();
    the_author_description();
    endif;
    rewind_posts(); ?>
  7. Mischif
    Member
    Posted 7 years ago #

    It works! I'll admit, I wish the WP dev team would've made it so you could use the tag outside of the loop, but this is great!

  8. Sivar
    Member
    Posted 7 years ago #

    As I said... I think they did, but then some people might have the glorious idea to include them on pages where i.e. recent posts from different authors are being displayed, and then wonder why always the description for the first post's author appears, or on static home pages, or why it doesn't work if there are no posts, etc...

    Btw, the latter will happen to you, too... no posts - no author description.

Topic Closed

This topic has been closed to new replies.

About this Topic