WordPress.org

Forums

[resolved] have_posts() but for PAGES >> have_pages()? (5 posts)

  1. damassipappas
    Member
    Posted 7 years ago #

    I'm looking for a function that evaluates whether a User has written any pages. have_posts() works great for posts, but doesn't work for pages...

  2. Pages are posts. have_posts() will work for both of them.

    However, neither one will "evaluates whether a User has written any pages". You could use the get_pages() function and pass in an authors= parameter to get the pages by that author though.

  3. damassipappas
    Member
    Posted 7 years ago #

    Do you know what get_pages($authID) returns if the user has written no pages? I have a sub-section that I want to hide if get_pages returns some kind of 0 or 'false'. There is very limited documentation on this function

  4. Yes, it is rather poorly documented.

    Basically, it returns an array of the pages in question. Takes lots of possible parameters.

    Try something like this:

    if (empty(get_pages("author=".$authID))) {
    // no pages for authID
    }
  5. damassipappas
    Member
    Posted 7 years ago #

    Perfect. Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic