WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Use Author_the_description outside of the loop

[Resolved] Use Author_the_description outside of the loop

  • 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?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Link and a more detailed explanation of where (and on what page) you want to put the author description, plz…

    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

    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.

    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

    Yeah, my mistake ;)… how about this:

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

    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!

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Use Author_the_description outside of the loop’ is closed to new replies.
Skip to toolbar