Created
September 9, 2010 03:50
-
-
Save mattwiebe/571328 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A couple of functions for caching the global post object so that contextual | |
* stuff (eg: sidebars) still works after custom queries | |
* NOT for use with query_posts(). Real WP coders always do a new WP_Query. | |
*/ | |
function sd_cache_post() { | |
global $post, $sd_cached_post; | |
$sd_cached_post = $post; | |
} | |
function sd_revert_post() { | |
global $post, $sd_cached_post; | |
if ( is_object($sd_cached_post) && isset($sd_cached_post->ID) && $sd_cached_post->ID !== $post->ID ) { | |
$post = $sd_cached_post; | |
setup_postdata($post); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment