Posted By

errkk on 01/25/10


Tagged

sql wordpress category query posts


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fyreflyX


Query to get posts by category - Wordpress


 / Published in: PHP
 

  1. $pages = $wpdb->get_results("
  2. SELECT post_title, ID identificativo FROM wp_posts
  3. JOIN wp_term_relationships
  4. ON wp_term_relationships.object_id = wp_posts.ID
  5. JOIN
  6. wp_term_taxonomy
  7. ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
  8. JOIN
  9. wp_terms
  10. ON wp_term_taxonomy.term_id = wp_terms.term_id
  11. WHERE
  12. wp_terms.name = '" . GLOSSARYCAT . "'
  13. AND
  14. wp_posts.post_type = 'post'
  15. ");

Report this snippet  

You need to login to post a comment.