Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * This is a rather simple and contrived example but it illustrates how this
- * function can be used to temporarily change the post context.
- */
- $alt_post_content = override_post_context( 1234, function ( $post ) {
- ob_start();
- // Do whatever you need here. The $post variable, in this scope, is the
- // $post object we are currently working with.
- get_template_part('some/template');
- return ob_get_clean();
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement