Use the following functionto set views manually
function setPostViewsManually($postID, $viewCount) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
update_post_meta($postID, $count_key, $viewCount);
}
You can run this code by
<?php setPostViewsManually(get_the_ID(), 1234); ?>
The above code will set the view to ‘1234’ for the current post. Run this function carefully else your new views will always be ‘1234’ because this function will keep running every time.
Just use it once and remove the code.
Related Posts:
- Count & Display Database Queries
- Delete all post meta except featured image
- Set Display Name to first and last name (phpmyadmin SQL Query)
- Emojis getting converted to “?”
- How to replace values in WordPress DB using phpMyAdmin
- Delete all post meta except featured image Using SQL
- Accidentally deleted active_plugins portion of the wp_options DB table
- Show content from database
- WordPress database import: Row size too large
- WordPress Database Huge wp_usermeta Table
- Connection refused on locahost after importing database?
- Changing root password in PHPMyAdmin for WordPress Database when going live
- Can’t update WordFence Options, clear data manually
- Check if post id exist in table than only update instead of inserting new row
- How to migrate a database from a server to another
- how to count click tab menu and insert to database
- SELECT SQL_CALC_FOUND_ROWS with wordpress search
- Files on Localhost, Database on Server
- Backing up WordPress database and files
- wp_option table error while importing
- Installing local to live WP into subdirectory
- Delete user with only subscriber role
- Can’t log into wordpress site – I have made a new user and still cant access
- Is there any way to monitor a MySQL db and check what has changed?
- DB prefix not updating
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- I imported an restore an database and It shows #1067 – Invalid default value for ‘user_registered’
- I need to find posts that contain YouTube links without http:// or https:// prefix and add http:// to all of them
- Is there any defects for using same database prefix in WordPress for multiple sites?
- Migrating meta_key and meta_value from old theme to new one
- What is recommended data type and encryption type for password in a database
- syntax error for changing user role from database
- Duplicate database to roll back theme & content changes
- WP website showing blank page after moving from subdomain to main domain
- How to retrieve user data based on role using SQL?
- WordPress character set issue
- Missing latest posts and options after DB migration via phpMyAdmin
- Check if a database is well installed
- Changed meta_key value in structures, now dashboard shows zero users
- Options table – where does my values go?
- Database question while Migrating from one domain to another on same WebHost [Bluehost]
- Difference between partition key, composite key and clustering key in Cassandra?
- How SID is different from Service name in Oracle tnsnames.ora
- What is a relation in database terminology?
- Why WordPress choose data serialization over json_encode?
- Are There Any Plans for WordPress to Support Databases Other Than MySQL?
- Reset Post IDs to less than 64bit integer
- how can get database name in wordpress?
- Does WordPress use the InnoDB engine for MySQL by default?
- $wpdb->prepare() warning in WordPress 3.5
- Best way to import users, post and categories from an external database
- Performance tips for a large user base [closed]
- wp_options is GB in size
- Can’t update database after wordpress update from 3.8.1 to 4.4.1
- Why does WordPress rely on an fully qualified site_url with a 15-step plan for moving a site?
- WordPress and automated MySQL backups to a different host
- How can I create a Bible search engine via WordPress? [closed]
- Error establishing a database connection; After importing DB & Theme
- Get all images from this database table
- Delete transients in website
- Bulk-create posts from SQL database
- I am switching laptops. I host my WP server through MAMP. I want to transfer [closed]
- How can i customize the export personal data file?
- Auto login subdomain from main domain on single sites with different DB
- Logins from WP users table use on another page
- Error establishing a database connection problem in xampp saver
- I’m not able to get access to $wpdb [duplicate]
- WordPress database connection [closed]
- Changing between Local Host DB to Production DB and in reverse
- How to keep variable `$post` to using in another file
- Make changes of wp-db.php file persistent against updates
- Count post views in loop
- Change the default data installed when setting up WordPress
- Clear Terms from Taxonomy for Specific Post IDs?
- How to split the WordPress database?
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- $wpdb->get_var – What value is returned when zero records are found?
- SymmetricDS in dev + prod workflow?
- Fixing YARPP plugin FULLTEXT MySQL indexing
- Error establishing a database connection in wordpress site , website not opening
- wpdb Insert unknown post data dynamic foreach loop
- How do I use a database in a custom theme?
- How do you enable scripts on a WordPress installation in Softaculous?
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- How to rerieve comments and their replies from DB
- Inserting data with Geometry field
- Export only a part of the database for migration
- database error WordPress move from one hosting to other
- Select data from foreach loop and send it to wordpress database
- Error establishing database connection error during first WordPress run
- Same DB for live and dev versions
- update multiple user meta field based on another meta field
- After renaming MySQL database, I can no longer access my Blog page
- execute custom function on database connection error
- not saving post in wp_post wordpress database table
- How to add data from wordpress tables to new database tables you have created
- How to back-up a database on IIS
- Where are database files of a WordPress website?
- Order of search results based off of a backend custom field and also in alpha order
- How to find fresh (last modified) and sql backup?