Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dantetesta/bfb87a5129a74f5ff04d96a31e3e22af to your computer and use it in GitHub Desktop.

Select an option

Save dantetesta/bfb87a5129a74f5ff04d96a31e3e22af to your computer and use it in GitHub Desktop.
/*Desenvolvido por Dante Testa + ASK Jarvis*/
/*Coloque esse código no functions.php do seu tema */
function views_shortcode( $atts ) {
$a = shortcode_atts( array(
'print' => '0',
'count' => '0',
), $atts );
$print = $a['print'];
$count = $a['count'];
if($count == 1){
$views = get_post_meta(get_the_ID(), 'views', true);
$views++;
update_post_meta(get_the_ID(), 'views', $views);
}
if($print == 1){
$views = get_post_meta(get_the_ID(), 'views', true);
return $views;
}
}
add_shortcode( 'views', 'views_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment