Return to Snippet

Revision: 44439
at April 11, 2011 21:51 by linkmoises


Updated Code
<?php
	$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
	if (0 < $numeroposts) $numeroposts = number_format($numeroposts);
	echo $numeroposts;
?>

Revision: 44438
at April 11, 2011 21:51 by linkmoises


Updated Code
<?php
	$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
	if (0 < $numeroposts) $numeroposts = number_format($numeroposts);
	echo $numposts;
?>

Revision: 44437
at April 11, 2011 21:49 by linkmoises


Initial Code
<?php
	$numeroposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE (post_status = 'publish' AND post_type = 'miembros')");
	if (0 < $numeroposts) $numeroposts = number_format($numeroposts);
	echo $numposts;
?>

Initial URL

                                

Initial Description

                                

Initial Title
Contar posts en un custom post type

Initial Tags
post, wordpress

Initial Language
PHP