Created
July 4, 2022 17:17
-
-
Save shahzaibkhan/040eb1104cd935ac896718a3b52e66d7 to your computer and use it in GitHub Desktop.
track_post_views
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
<?php | |
function track_post_views ($post_id) { | |
if ( !is_single() ) return; | |
if ( empty ( $post_id) ) { | |
global $post; | |
$post_id = $post->ID; | |
} | |
set_post_views($post_id); | |
} | |
add_action( 'wp_head', 'track_post_views'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment