Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    New Coder
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post

    Question WordPress script not working correctly :S

    Hello,

    I made this script to check to wherever the 'Author Bio' is empty or not if empty then display a little message saying 'This author does not have a description yet...' but if the author does have a description then it will display their bio.

    But the problem I'm having is that it displays the 'Author Bio' also the message that is shown when the Author doesn't have a bio???

    Here's the code:

    PHP Code:
    <?php
    if ( the_author_meta('description') == '' ) {
    echo 
    '<em>This author does not have a description yet...</em>';
    } else if(
    the_author_meta('description')) { echo the_author_meta('description'); }
    ?>
    Yet very simple code, but can't understand why it's doing that unless WordPress is doing something to it... If anyone could help me solve this I would greatly appreciate it

    Thanks in advance!
    Last edited by bennyy007; 06-29-2010 at 09:08 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,503
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Just a shot in the dark ... else instead of else-if ...

    Try:
    PHP Code:
    <?php
    if ( the_author_meta('description') == "" ) {
    echo 
    "<em>This author does not have a description yet...</em>";

    else {
    echo 
    the_author_meta('description'); 
    }
    ?>

  • #3
    New Coder
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Thanks for the reply mlseim,

    But that doesn't seem to solve it I've tried so many ways with this, but yet still no luck...

  • #4
    Regular Coder xconspirisist's Avatar
    Join Date
    Jun 2006
    Location
    Great Britain.
    Posts
    138
    Thanks
    1
    Thanked 6 Times in 6 Posts
    PHP Code:
    <?php

    $description 
    the_author_meta('description');

    if (empty(
    $description)) {
        echo 
    '<em>This author does not have a description yet...</em>';
    } else { 
        echo 
    $description;
    }

    ?>
    If that does not work, look at the output of this script to see what wordpress is actually giving you:

    PHP Code:
    $description the_author_meta('description');
    var_dump($description); 
    If I have been helpful, use the "thank" button - It makes me happy!

    xconspirisist.co.uk - homepage of my online alias
    technowax.net - a community for people interested in all forms of modern technology.

  • #5
    New Coder
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    I'll try that now...

  • #6
    New Coder
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    It gives me this: NULL

  • #7
    New Coder
    Join Date
    Jun 2009
    Location
    Manipal
    Posts
    45
    Thanks
    2
    Thanked 3 Times in 3 Posts

  • #8
    New Coder
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    What am I meant to be looking at? I've been on that page yet provides the correct variables to use and so on but nothing checking against them but thanks though

  • #9
    New Coder
    Join Date
    Jun 2009
    Location
    Manipal
    Posts
    45
    Thanks
    2
    Thanked 3 Times in 3 Posts
    I guess you should use :
    get_the_author_meta()

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

  • #10
    New Coder
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Ah that well yes in a way but that's like checking against all, I could be very wrong on that but and I've tried it but still does what it did before. Not really sure why WP doesn't like this kind of method of checking

  • #11
    New Coder
    Join Date
    Jun 2009
    Location
    Manipal
    Posts
    45
    Thanks
    2
    Thanked 3 Times in 3 Posts
    There is something wrong you are doing. Which file are you editing ?

  • #12
    New Coder
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Single.php

  • #13
    New Coder
    Join Date
    Jun 2009
    Location
    Manipal
    Posts
    45
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Try debugging with Firebug or just view the source and see where the author bio is displayed.

  • #14
    New Coder
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Well I know where it is as I've manually put it in the single.php file...

    The code:

    PHP Code:
    <!-- get the author bio -->
    <div class="authorprofile">
    <div id="authorInfo">
    <div id="aheading" class="style1">About the Author</div>
    <div id="aboutauthor">
    <?php

    $description 
    the_author_meta('user_description');

    if (empty(
    $description)) {
        echo 
    '<em>This author does not have a description yet...</em>';
    } else { 
        echo 
    $description;
    }

    ?>
    </div>
    <div id="wrapbtm">
    <div id="followontwit"><a href="<?php the_author_meta('twitter'); ?>">Visit <?php the_author_meta('first_name'); ?> on Twitter</a></div>
    <div id="visitauthpage"><a href="<?php the_author_meta('user_url'); ?>">Visit <?php the_author_meta('first_name'); ?>'s Website</a></div>
    </div>
    </div>
    <div id="authorPic">
        <?php echo get_avatarget_the_author_email(), '100' ); ?></div>
    </div>

  • #15
    New Coder
    Join Date
    Jun 2009
    Location
    Manipal
    Posts
    45
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Try :

    PHP Code:

    $description 
    get_the_author_meta('user_description'); 
    By the way, what is displayed if the user doesn't have a bio ?

  • Users who have thanked kar2905 for this post:

    bennyy007 (06-29-2010)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •