SELECCIONAR POST POR CATEGORIA SIN WORDPRESS Y MYSQL


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

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


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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.