Ready to get started?Download WordPress


Check if author has posted anything (4 posts)

  1. simophat
    Posted 4 years ago #

    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?



  2. vtxyzzy
    Posted 4 years ago #

    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.

  3. simophat
    Posted 4 years ago #

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

  4. vtxyzzy
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic