Put this into your functions.php file:
function userfunc_get_post_views($postID) {
global $post_stats;
foreach ( $post_stats as $p ) {
if ( $p['post_id'] == $postID ) { ?>
<span class="stats-post-views">
<?php echo number_format_i18n( $p['views']) . ' views'; ?>
</span>
<?php }
}
}
and then into your single.php file where you want the views to be displayed:
<?php userfunc_get_post_views(get_the_ID()); ?>
This will wrap it in a div with the class of stats-post-views so you can style it.
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
- How To Ignore a Filter On Applying Filter the Content In a Function
- post expire after x days
- Accessing post’s meta data based on user’s click of a post
- How do I “get the next 10 posts after post_id == x”?
- Preg Match All doesn’t Allow echo first character for WordPress Taxonomy Tags
- External RSS feed to WordPress Portfolio
- pagination on data fetched using SQL query
- How to delete all trashed item in one-go
- Allowing users to Sign-up > Login > Post articles that need approval
- Pass user role to javascript code inside body
- How to use custom Javascript code inside a plugin?
- Creating an admin meta box to save post as pending
- Get data from wp_posts of mysql in to variables of wordpress-php script
- WP Insert Post If user refreshes override new post
- WordPress is redirecting me to homepage
- WordPress hide post from custom post-type on a single page
- How can I see $post object in frontend from functions.php?
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Failed to load resource: the server responded with a status of 500 () post.php
- How to echo a PHP Code After the Content
- How to change text in a page by utilizing a custom user id?
- Displaying friend’s posts only
- Trending Tags based on post views
- Enforce conditions only for draft posts using WyPiekacz, ignore pending and published posts
- PHP $_session is not work in wordpress
- Redirect a specific User role not admins automatically to view the post that they just updated
- is_singular() in mu-plugins not working
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- Customizing subject in comment notification e-mails
- How to work with Syntax Highlighter Evolved?
- User-Specific Timezones? Hack? Plugin?
- Plugin or mod for wordpress to make content publication SUPER easy
- jQuery plugin only in one page/post
- How to extract images of post and pages excluding header and logo image in wordpress?
- Dynamic HTML not displaying at respective place
- How to filter content post only on save
- Pass a php string to a javascript variable
- Show price with Geo IP location
- How to generate video out of images via WordPress plugin
- How to get 1 or 2 specific posts on top of my wordpress blog?
- How to ‘clone’ a wp plugin to make small changes
- With W3 Total Cache when I publish a post it does not appear in the homepage. Only if i purge all cache [closed]
- Hiding posts – WP Hide Post not working
- Scripts at the end of the page
- Any built-in function to associate a post to category through a plugin?
- How can I add hyperlink in WP_Error message?
- How to save inputed data in a textbox [EDITED] [duplicate]
- Replace default og:image tag YOAST
- WordPress Payment gateway add on form , how to add form into list or else how to submit form to next step for payment
- How to get my plug-in, wrote in php, to refresh on its own every 5 minutes?
- How to Create a shortcode to this php function
- Would Gutenberg be considered a PlugIn?
- My single.php page does not show the related data to the post which is clicked
- Creating a CSV with PHP inside the plugin directory
- Check if variable is set in filter
- Access a particular field in an array
- How to connect rating to individual comments?
- JQuery prepend a function
- How to create plugin/ page that reads from database
- I am trying to make a field show and save from quickedit screen
- Send email with list of active plugins upon activation/deactivation
- Add the_post_thumbnail_url to a shortcode in function.php
- Adding a Tag Parameter / Filter to My Shortcode
- Link Posts to External URL
- Pasting this PHP breaks my page. Why?
- Check against server time to display SQL entries – Radio Station DJ Rotator Plugin
- After installing JetPack, can I delete the WordPress stats plugin?
- can’t unzip file
- WordPress jQuery Post – Amending Variable Value Within Function Command
- how to display recent post by category on home page
- WordPress Custom Hook with Class method
- Open_basedir errors – But setting basedir to none redults in 502 Bad Gateway
- Auto delete empty posts
- Change plugin descriptions
- How to display the custom post related blog by category?
- WP Forms not displaying,becomming an fatal error
- How can I find related learndash course id from woocommerce product object?
- How to use Datatable with Ajax when creating plugin on WordPress?
- Pagination (including title of each page) in a post for a long posts
- Showing how many times is plugin activated or deactivated
- Redeclare a plugins function/class in my theme?
- get/show Last ID
- Form tries to download a file on submit
- Add Filter to get_next_posts_link
- How to echo a plugin’s function into a template?
- Retrieve data from multiple WordPress sites using PHP script
- It possible to implement an adhoc php web application with wordpress?
- Jetpack Comments Change Placeholder Text
- Auto create description in post
- Edit Buddypress Groups Activity Page Text [closed]
- Retrieve post thumbnails
- How to prevent page load on form submission
- how to add “alt” for all image in wordpress
- WordPress: code structure
- How to add a text in the checkout page woocomerce?
- How to fix template and image buffering issues on website [closed]
- PHP FATAL ERROR