Query to get posts by category - Wordpress


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.