Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * This is a rather simple and contrived example but it illustrates how this
  5. * function can be used to temporarily change the post context.
  6. */
  7. $alt_post_content = override_post_context( 1234, function ( $post ) {
  8. ob_start();
  9.  
  10. // Do whatever you need here. The $post variable, in this scope, is the
  11. // $post object we are currently working with.
  12. get_template_part('some/template');
  13.  
  14. return ob_get_clean();
  15. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement