Instálalo en 1 minuto: copia y pega este script en tu functions.php.
// Contador de visitas simple para WordPress
function ee3_count_post_views() {
if ( is_singular(['post','page']) ) {
$post_id = get_queried_object_id();
$views = (int) get_post_meta( $post_id, 'ee3_post_views', true );
update_post_meta( $post_id, 'ee3_post_views', $views + 1 );
}
}
add_action('template_redirect', 'ee3_count_post_views');
function ee3_show_post_views($content) {
if ( is_singular(['post','page']) && in_the_loop() && is_main_query() ) {
$views = (int) get_post_meta( get_the_ID(), 'ee3_post_views', true );
$icon = '👁️';
$html = ''
. $icon . 'Visitas: ' . $views . '';
return $content . $html;
}
return $content;
}
add_filter('the_content', 'ee3_show_post_views');
👁️ Visitas: 123