Posted By

manavecplan on 09/12/10


Tagged


Versions (?)

Includes shortcode


 / Published in: PHP
 

URL: http://digwp.com/2010/06/shortcode-for-includes/

  1. function digwp_includeContentShortcode($atts) {
  2.  
  3. $thepostid = intval($atts[postidparam]);
  4. $output = '';
  5.  
  6. query_posts("p=$thepostid&post_type=page");
  7. if (have_posts()) : while (have_posts()) : the_post();
  8. $output .= get_the_content($post->ID);
  9. endwhile; else:
  10. // failed, output nothing
  11. endif;
  12. wp_reset_query();
  13.  
  14. return $output;
  15.  
  16. }
  17.  
  18. // USAGE
  19. // In the post content, you can use [digwp_include postidparam="1234"]
  20. // "1234" would be the WordPress ID of the Page you are trying to include
  21.  
  22. add_shortcode("digwp_include", "digwp_includeContentShortcode");

Report this snippet  

You need to login to post a comment.