Posted By

linkmoises on 04/11/11


Tagged

post wordpress type count custom contar


Versions (?)

Contar posts en un custom post type


 / Published in: PHP
 

  1. <?php
  2. $numeroposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE (post_status = 'publish' AND post_type = 'custom-post-type')"); // reemplazar "custom-post-type" por el slug del custom post type seleccionado
  3. if (0 < $numeroposts) $numeroposts = number_format($numeroposts);
  4. echo $numeroposts;
  5. ?>

Report this snippet  

You need to login to post a comment.