[wp-hackers] Best way to verify if a post_id is valid
Hikari
lists at hikarinet.info
Tue Feb 23 15:47:19 UTC 2010
tnx for the suggestions everybody! ^^
---------------------------
Hikari - A Luz ilumina a PAZ
http://Hikari.ws
http://ConscienciaPlanetaria.com
Tenha seu próprio email meunome @ ConscienciaPlanetaria.com.br!: http://seunome.ConscienciaPlanetaria.com.br
----- Original Message -----
From: "Jeremy Clarke" <jer at simianuprising.com>
To: <wp-hackers at lists.automattic.com>
Sent: Monday, 22 February, 2010 1:31 PM
Subject: Re: [wp-hackers] Best way to verify if a post_id is valid
| As stated above the most basic (and probably the most efficient way)
| would be to do a get_post($id) then check the status and type
| properties to make sure they are what you want, in which case you'd
| already have a nice post object to use.
|
| Alternately if you wanted just one call to check you could use
| get_posts() and include arguments for the properties you want to
| check. In this case 'publish' status and 'post' type are the defaults,
| so if there are any results then the ID exists. I don't feel like
| digging into the source, but I think get_post() will probably be
| faster though, as it will only check one row in the DB.
More information about the wp-hackers
mailing list