• Resolved vince2006

    (@vince2006)


    I’d like to make it so on a PAGE that I can have an image link that links to the author’s post page to go to https://thesite.com/author/joe but only if the author has posts…

    If have looked at the forums and found this code and it appears to be close to what I need…

    ‘<?php $desc = get_the_author_description();
    if ($desc!=”) { // The description is not empty
    echo ‘<i>Posted by: ‘;
    the_author_posts_link();
    echo ‘</i>’;
    }
    else {
    echo ‘<i>Posted by: ‘;
    <?php the_author_nickname(); ?>
    echo ‘</i>’
    }
    ?>’

    and I am trying to write it so that if there are posts, then an image will display on the page that links to the author’s post page..

    so if the author has posts, then display…

    <img src=”/images/my_img.jpg” width=”200″ height=”40″ border=”0″>

    but if the author does not ahve posts, then display nothing…

    Can anyone shed some light on this for me?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH

    (@michaelh)

    Untested, but in The Loop this should work

    if (get_usernumposts($post->post_author)) {
    // your author has posts
    }

    Thread Starter vince2006

    (@vince2006)

    That is exactly what I could not figure out! Thanks very much!

    Thanks for the tip Michael!

    Here is the resulting code for anyone that wants to do the same thing…

    <?php
    # get author login name for auto posts button
    $author = get_the_author_login();
    if (get_usernumposts($post->post_author)) {
    // your author has posts
    echo "<a href='/author/$author'><img src='/images/my_img.jpg' width='200' height='32' border='0' alt='My Posts'></a>";
    }
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Turn on author_posts_link if author has posts’ is closed to new replies.