Support » Fixing WordPress » have_posts() but for PAGES >> have_pages()?

  • Resolved damassipappas


    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…

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    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.

    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

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    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

    Perfect. Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘have_posts() but for PAGES >> have_pages()?’ is closed to new replies.