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]
- Help required with local wordpress setup
- #1067 – Invalid default value for ‘post_date’ when trying to create a new column
- WordPress Admin login problems- PLEASE HELP [closed]
- Deleting WordPress posts and media files based on author via MYSQL database
- Database table prefix different between wp-config.php and in database
- Count views without get_post_meta
- What is an ORM, how does it work, and how should I use one? [closed]
- What is the difference between an ORM and an ODM?
- What is this JavaScript “require”?
- Rename a table in MySQL
- How should I tackle –secure-file-priv in MySQL?
- What is this JavaScript “require”?
- What is “Advanced” SQL?
- What’s the difference between identifying and non-identifying relationships?
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- What are the differences between B trees and B+ trees?
- MySQL SELECT increment counter
- How to resolve ORA-011033: ORACLE initialization or shutdown in progress
- Example of a strong and weak entity types
- Oracle SQL query for Date format
- phpMyAdmin – Error > Incorrect format parameter?
- Strange Characters in database text: Ã, Ã, ¢, â‚ €,
- 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?
- Failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user ‘root’@’localhost'(using password:YES)
- Database vs File system storage
- Can I have multiple primary keys in a single table?
- How to create a foreign key in phpmyadmin
- importing a CSV into phpmyadmin
- Exclude Statement in SQL
- How do you query for “is not null” in Mongo?
- What is a file based database?
- Is it fine to have foreign key as primary key?
- Storing Images in DB – Yea or Nay?
- Using wpdb to connect to a separate database
- how to Optimize WordPress database for 10 million post? [duplicate]
- MySQL Database User: Which Privileges are needed?
- Why is my database import losing text widget data?
- Database synchronization between dev/staging and production
- Keeping WP database synced across multiple developers using git
- WPDB Insert or if exists Update
- Multiple developers / editors working on a site in progress
- How can I make updates to a site, on a development copy, but then move updates back without overriding live site’s evolving database?
- get_results using wpdb
- Will it break my site if I delete all transient records in wp_options table?
- Checking if Database Table exists
- Why WordPress choose data serialization over json_encode?
- What’s the simplest way to backup my WordPress database?
- WordPress (MyISAM) database is slow, should I switch to InnoDB?
- $wpdb won’t insert NULL into table column
- Relaunch 4.2 utf8mb4 database upgrade
- Fastest way (least amount of steps) to locally import a remote database using WP-CLI
- Safest way to bulk delete post revisions
- Please explain how WordPress works with MySQL character set and collation at a low level
- Solution for database version control and deployment?
- The MySQL alternatives: Do Percona Server and MariaDB work well with WordPress, and do they make WordPress go better?