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]
- 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
- Check if an option exists and get its value in one hit
- Change options table prefix only
- What’s the proper way to sanitize checkbox value sent to the database
- Problems with moving my WordPress site to another domain/server
- Is it important to have integers inserted using %d rather than %s?
- Export a custom Mysql database product catalog to WordPress
- Any risk to changing WP table col CHARACTER_MAXIMUM_LENGTH?
- Why this query is not showing any result on wordpresss home page?
- Reinstalling wordpress from database breaks the site
- Adding prefix to WordPress database tables breaks admin capabilities?
- What is the best way to resurrect and update my old WordPress site?
- Trouble running $wpdb->query() with last_insert_id
- Using $wpdb | checking entered email against existing emails in db
- wp-cli: Error establishing a database connection: undefined constant DB_USER
- Add pdf to a website
- Can I customised default WP table
- Woocommerce – Check product stock availability from external database
- Get results from wordpress data custom table
- Outputting query results
- Help With a Large WordPress Based MySQL Database on Shared Hosting
- Will adding & modifying default WordPress table index break future WordPress update
- why the posts queried from sql is more than those showed on the page?
- Database migration issues – Error #1046 No database selected
- echo site_url() returns a different value than what is in the database siteurl field
- Can two domains use the same database?
- Search Character Set Problem
- How to get the full stack trace for WordPress “table doesn’t exist” error in debug.log?
- How to fix Uploaded to this post option to see group of images uploaded to a post?
- adding user_id and name to a separate table whenever a user register based on role
- How to access a table in a wordpress database using REST API?
- How do I loop/iterate through posts to edit all img tags?
- User saved through WordPress backend does not show up in database table users
- How to optimise this database query?
- Adding featured for post using database
- get_the_terms is not working
- Store id from database query in cookie
- Split database on large site?
- Return image urls with specific base string?
- What WordPress file is saving new users to database
- Restoring .sql backup results in “Error establishing a database connection”
- Link to handle $_GET request
- WordPress sync with phpbb
- “MySQL server has gone away” since update to 3.8
- Getting deleted users in database
- Options of accessing wordpress data from mobile app
- Getting data from a table using a query
- Database interaction (private-public) [closed]
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- How to properly configure SSL connection to remote azure database for running queries within a WordPress environment
- Database Queries are crashing the server
- Uploading to WordPress Database
- Database Errors since site updated to WordPress 6.4.3
- $wpdb->update is not working until next page refresh. Is there one more step?
- Merging multiple WP databases into one for a multilanguage site prevents access to language-specific WP administration
- How to change all the images in post content to full/orginal size – Thumbnails are broken
- Can I Load posts from an External database if the post is not found on Main WordPress Database