Created
August 23, 2022 16:56
-
-
Save dantetesta/bfb87a5129a74f5ff04d96a31e3e22af to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /*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