kisukedeath

Wordpress snippets

Sep 6th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. Wordpress Snippets
  2. ------------------------------------------------------------------
  3. <?php
  4. query_posts('post_id=548&post_type=parks');
  5. while (have_posts()): the_post();
  6.    the_title();
  7.    the_content();
  8. endwhile;
  9. ?>
  10.  
  11. <?php
  12. $my_query = query_posts('post_id=548&post_type=parks');
  13. global $post;
  14. foreach ($my_query as $post) {
  15.    setup_postdata($post);
  16.    the_title();
  17.    the_content();
  18. }
  19. ?>
  20.  
  21. <?php
  22. $ids = array(548,555,587,583,585);
  23. $my_query = query_posts(array('post__in' => $ids,'post_type'=> 'parks'));
  24. global $post;
  25. foreach ($my_query as $post) {
  26.    $posts_by_id[$post->ID] = $post;
  27. }
  28. foreach ($ids as $id) {
  29.   if (!$post = $posts_by_id[$id]) continue;
  30.    setup_postdata($post);
  31.    echo '<p>TITLE: ';the_title();echo ' - ';the_ID(); '</p>';
  32.    the_content();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment