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  

Comments

RSS Icon Subscribe to comments
Posted By: robertfcrocker on September 14, 2017

This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog.. you can try here

You need to login to post a comment.