What is the best way to get the page or post ID in a sidebar widget? I am trying to make sidebar widgets that do things like display a list of related file attachments for that page/post.
What is the best way to get the page or post ID in a sidebar widget? I am trying to make sidebar widgets that do things like display a list of related file attachments for that page/post.
Hi,
You can use like below:
$post_id = $GLOBALS['post']->ID;
Very close to my need !
I'm looking for this for category without post_id defined.
Any solution ?
If you are trying to display the category id for all/one category look at Function_Reference/get_categories.
If in admin you are looking for the id see:
How do I determine a Post, Page, Category, Tag, Link, Link Category, or User ID?
This topic has been closed to new replies.