Created
November 28, 2022 22:57
-
-
Save MarceloGlez/48d6ce29f1a102e109e0eea5986bd964 to your computer and use it in GitHub Desktop.
Crea un shortcode para mostrar cantidad de post de un CPT en Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Muestra el total de posts de un CPT - reemplaza ('cpt'), usar shortcode: [cantidad_cpt] */ | |
function shortcode_total_cpt($atts) { | |
return wp_count_posts('cpt')->publish; | |
} | |
add_shortcode('cantidad_cpt', 'shortcode_total_cpt'); | |
/* Muestra el total de posts del blog genérico, usar shortcode [cantidad_post] */ | |
function shortcode_total_post($atts) { | |
return wp_count_posts('post')->publish; | |
} | |
add_shortcode('cantidad_post', 'shortcode_total_post'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment