Contar posts en un custom post type


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



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

You need to login to post a comment.