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
- Updating post_parent caused the website to become unresponsive for 40 seconds or more
- Use wordpress plugin in codeigniter
- How passing values to construct function with Actions?
- Inserting custom PHP script on homepage
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Is wp-app.php or wp-apps.php needed for WordPress?
- add_action into another add_action not working
- Call plugin with php function
- How to get the first post and second post in a wordpress blog?
- Is it possible to send blog posts via email to subscribers?
- Custom setup of wordpress comments that are displayed
- Is there any plugin which can paste a common content to my every post?
- Duplicate results are displayed in a custom plugin [closed]
- Recent posts per category loop?
- ‘Organize Series Plugin’ as muti author feature
- Check if variable is set in filter
- Finding the screen id of a page generated with add_menu_page
- WordPress custom taxonomy not showing
- My WordPress site when down after installing a plugin and now all I get is a simple white screen [closed]
- Access a particular field in an array
- Notice: Uninitialized string offset: 0 in social sharing mu-plugin
- Why is my custom post type not being activated on plug-in activation?
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- How to add apply_filter for a class property in plugin
- Import Instagram post to WordPress blog post
- Issue running db create table query from static method
- Problem of encoding characters (apostrophes) in my posts publications
- Only allowing some emails to create an account [closed]
- Warning: Use of undefined constant list_all – assumed ‘list_all’ (this will throw an Error in a future version of PHP)
- How to backup single post in wordpress [closed]
- How to distinguish if a plugin is not installed or just not active
- JavaScript in a PHP plugin
- Checking the count within a foreach loop
- Does having more than 30 Admin Ajax affects site performance (plugin)?
- execute function after one completed
- Can i add custom code in Source, Header from function.php?
- WHy custom plugin slows down the loading of the pages?
- How to make multiple admin pages for one plugin?
- How to show the number of website visitors in my theme
- Setting Up PHP Workflow in WordPress
- php code crashes site – possible syntax error
- Include a php file from another plugin
- How to get all posts belongs to a user between a certain date
- wordpress add_action() issue in ajax call
- Add bcc to contact from on wordpress
- What happens when WordPress memory limit is exceeded?
- Register Script in Plugin Widget
- Using ‘mysqli_connect’ ‘crashes’ WordPress client-side
- How do I publish portfolio items with a future date?
- Basic function call on init failing
- Is it possible to remove subscription box from Jetpack stats page? [closed]
- Problem with isset and $_POST
- Getting taxonomy images to display on single-post with their terms
- How can i force wp-admin to use 2-column dashboard layout? [closed]
- Adding media upload button to User Profile page (following a tutorial)
- wordpress content .php file in an iframe’s src in a wordpress post
- Cropping images from top center using Jetpack Photon
- How can I exclude a dynamic URL to show a popup created using ‘WordPress Popup’ plugin
- How to connect rating to individual comments?
- Edit / Change Jetpack Mobile Theme [closed]
- iframe not showing in post (with “allow php in posts” plugin activated)
- how can I do something on new user registration?
- JQuery prepend a function
- Minimizing scripts & css files that plugins add
- Making my plugin create a page?
- Why can’t I call a (member) function from within a foreach?
- Is there a way to make the main page only display a brief description of the full article?
- How to change the post form from plugin?
- WordPress plugin Post Creation [closed]
- Get ‘Headers already sent’ error for the plugin I am creating when I try to login
- WordPress Related Plugin – only show when related content