Posted By

serialk89 on 06/15/11


Tagged

mysql php wordpress categoria


Versions (?)

SELECCIONAR POST POR CATEGORIA SIN WORDPRESS Y MYSQL


 / Published in: PHP
 

Selecciono los post por categoría desde la base de datos de wordpress

  1. <?php
  2. //consulta todos los empleados
  3. $sql = mysql_query("SELECT DISTINCT post_name,post_title,post_excerpt
  4. FROM wp_o0qb3z_posts, wp_o0qb3z_term_relationships, wp_o0qb3z_term_taxonomy
  5. WHERE wp_o0qb3z_term_relationships.object_id = wp_o0qb3z_posts.id
  6. AND post_status = 'publish'
  7. AND post_type = 'post'
  8. AND wp_o0qb3z_term_taxonomy.term_taxonomy_id = wp_o0qb3z_term_relationships.term_taxonomy_id
  9. AND wp_o0qb3z_term_taxonomy.taxonomy = 'category'
  10. AND wp_o0qb3z_term_taxonomy.term_id = 'EL ID DE LA CATEGORIA'
  11. ORDER BY post_date DESC
  12. LIMIT 10 ",$link);
  13.  
  14. while($row = mysql_fetch_array($sql)){
  15.  
  16. echo '<div>'.$row['post_title'].'</div><br />';
  17.  
  18. }
  19. ?>

Report this snippet  

You need to login to post a comment.