What's the difference between global var post and get_post? <p>I use the_posts filter to add an object to each queried post. When access the added object, I get different result by using <code>$post</code> or <code>get_post</code>.<br> This is the code to attach the object to posts:</p> <pre><code>add_filter( 'the_posts', 'populate_posts_obj', 10,2 ); function populate_posts_obj( $posts, $query ){ if ( !count( $posts ) || !isset($query-&gt;query['post_type']) ) return $posts; if( in_array( $query-&gt;query['post_type'], get_valid_grade_types())){ foreach ( $posts as $post ) { if ( $obj = new Gradebook( $post-&gt;ID ) ) $post-&gt;gradebook = $obj; } } return $posts; } </code></pre> <p>Then, access the obj via <code>$post</code>, sometimes get the obj, sometimes not (even when it's the same post):</p> <pre><code>function get_the_gradebook(){ global $post; return isset($post-&gt;gradebook) ? $post-&gt;gradebook : null; } </code></pre> <p>Access the obj via <code>get_post()</code>, always get the obj:</p> <pre><code>function get_the_gradebook(){ global $post; $p = get_post($post-&gt;ID); return isset($p-&gt;gradebook) ? $p-&gt;gradebook : null; } </code></pre> <p>I can just use the <code>get_post()</code> version, but it would be useful if I know why the difference.</p> <h3>Additional info:</h3> <p>If you ask the reason I attach an obj to each post, I think WordPress may take care of the caching process at the first place. Then, other caching plugins can work on my obj as if working on standard WP posts.</p>