[wp-hackers] Hooks, Actions, Filters

Jeremy Clarke jer at simianuprising.com
Thu Jul 30 15:04:48 UTC 2009


On Thu, Jul 30, 2009 at 1:50 AM, Bruno Alexandre<bruno.in.dk at gmail.com> wrote:
> where and how do I know what to expect from that? And what about if I was
> expecting $id (page id)...

Just to quickly answer this other question. Some filters and actions
pass multiple values so that you can also have information like
page/post id. In this case its not available though.

Luckily one thing that tends to work for situations like this is to
globalize $post. If you're in the loop or on a single article page
(whether in the admin or frontend) $post normally contains the full
object for the post being worked on.

So in your filter function you can probably do:

global $post;
echo $post->ID;

Note that $post is used even if its a page.

-- 
Jeremy Clarke | http://jeremyclarke.org
Code and Design | http://globalvoicesonline.org


More information about the wp-hackers mailing list