I'm trying to attach an object to every post of any type. This will require post ID to populate or create my object. So, I either call global $post, or get_the_ID(), or do get_post(). I hope there is a simple way to do the job, and I found a plugin "wp-post-ratings" uses global $id, it gets the id within the loop. I wonder if this is a WP global, or it's the plugin's custom code?
|
|
|||
|
|
|
If you are using netbeans and xdebug, or have set up your debugging environment correctly then you can observe the variables, objects e.t.c as they change. To see when they are created and what is contained within objects such as wp_query or wp_rewrite your posts->ID is set once the function wp() is called in wp-blog-header.php. I know you asked where the ID is set but you can use this to find other variables and objects that are set by stepping through the wordpress environment. That is if you develop your wordpress sites locally.
|
|||||
|
|
You can retrieve an ID from the I would say if you want to ensure you're getting the actual page/post/item id then to access
|
|||||
|
|
$id is one of the global variable available only from inside the loop. If you want to modify content of every post, wordpress has a hook for that called the_content |
|||
|
|
Yup, It is a global variable but works only inside Wordpress loop. While inside the loop, Reference - Codex - Inside the Loop variables |
||||
|
|

