another (wp 2.3.3) custom loop query example


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php if (is_page('about')) {
  2.  
  3. $sql = "SELECT posts.* FROM $wpdb->posts posts INNER JOIN $wpdb->term_relationships termrel ON posts.ID = termrel.object_id WHERE termrel.term_taxonomy_id = 8";
  4.  
  5. $about_posts = $wpdb->get_results($sql, OBJECT);
  6.  
  7. ?>
  8.  
  9. <?php if ($about_posts) {
  10.  
  11. ?>
  12.  
  13. <ul class="practitioner_list" id="practitioner_list">
  14.  
  15. <?php foreach ($about_posts as $aboutpost) {
  16.  
  17. ?>
  18.  
  19. <li><a href="<?php echo $aboutpost->guid; ?>"><?php echo $aboutpost->post_title; ?></a>
  20. <p><?php echo $aboutpost->post_excerpt; ?></p></li>
  21.  
  22.  
  23. <?php } ?>
  24.  
  25. </ul>
  26.  
  27. <?php } ?>
  28.  
  29. <?php } ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.