WordPress.org

Support

Support » How-To and Troubleshooting » Check if author has posted anything

Check if author has posted anything

  • Hey there!
    wondering if anyone can help.

    I have a blog where some authors are advisers who post and some are just advisers who do not post on the blog.

    I have built an author page which lists the advisers.

    I want to check whether a user has made any posts and display a “read posts by this author” link next to their name if they have.

    The page i am displaying the user info is based on selected user IDs. The page sits outside the loop. Basically I have built an array of user IDs and i am looping through this array and displaying info on each of the users (photo, name, nickname and description) by using the get_userdata function.

    So what i want to do is display a “read posts by this author” next to this user data, but only display the link if the user has actually posted an article on the blog.

    Any ideas on how to do this?

    Thanks

    Simon

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can use the count_user_posts() function as described here in the Codex. If the return value is greater than zero, show the link.

    wierd… that function should work but it didnt.
    ended up using: get_usernumposts
    which seems to be outmoded but still works in my version.

    thanks for the help vtxyzzy? !

    You are welcome! Now, please use the dropdown on the right to mark this topic ‘Resolved’.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Check if author has posted anything’ is closed to new replies.