• BH

    I was a bit surprised at coming up empty after searching for an answer to this – maybe I’m just not looking correctly.

    I have taken to using custom queries for various plugins, extensions and functionality. Most recently I implemented a custom post type for events which stores a timestamp as meta data. By selecting rows with timestamps greater then time() I am able to retrieve all future events, and of course less than time() is past events.

    Is there any resource that lists the various issues to watch for when writing a custom query to get a post, things like post_status == trash, or == revision?

    If there is and I am not finding it, would someone kindly point me to it? If there is not, it would make a good addition to the online documentation.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Getzel Rubashkin

    (@fardak)

    Clarification: revision is stored in post_type, so it would be post_type == revision.

    Thread Starter Getzel Rubashkin

    (@fardak)

    I just stumbled across posts_where which allows the addition of WHERE clauses to the loop or query. This seems to be the solution to this problem. I don’t need it for anything currently on my to do list, so I haven’t tested it yet, but I am posting it here in case anyone stumbles on this post. It looks like a very useful function.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit custom select to non-revision, non-trash rows’ is closed to new replies.