get_post_meta function returning post ID, not view count
-
I’m trying to use this plugin in conjunction with the Code Snippets plugin so I don’t have to edit the underlying theme’s code. (My theme updates fairly frequently.) Thus I’m trying to put the view # code in the post text itself, not the underlying PHP code.
The normal
echo get_post_meta( $post->ID, ‘jetpack-post-views’, true );
code doesn’t work, I’m assuming because the $post variable doesn’t exist in the post text scope.
I then tried
echo get_post_meta( (int)the_ID(), ‘jetpack-post-views’, true );
but that only outputs the post ID. Running
echo (int)the_ID();
prints the post ID fine, so I know it’s getting the post ID okay. What’s going on?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘get_post_meta function returning post ID, not view count’ is closed to new replies.