you can read your file using standard PHP:
$value = json_decode( file_get_contents( 'path/to/your/file.json' ) );
Then you can use WordPress function to update post meta:
update_post_meta( $post_id, $meta_name, $value, $prev_value );
$post_id = ID of the post you want to update
$meta_name = name of the meta field you want to update
$value = new value
$prev_value = only posts with this value will be updated (so if you want to only switch yes to no, you can put “yes” there.
If you want to use SQL:
global $wpdb;
$wpdb->query(
$wpdb->prepare( 'UPDATE ' $wpdb->prefix . 'postmeta ON meta_value = %s WHERE post_id IN (%s);', $value, join( ',', $post_ids ) )
);
$post_ids = array of all post IDs that should be updated
$value = your new value
Related Posts:
- How to return number of found rows from SELECT query
- Can i use php sql functions instead of $wpdb?
- $wpdb->delete column values IN ARRAY()?
- Custom query to get post names beginning with a digit
- WordPress get pagination on wpdb get_results
- Ajax $wpdb not returning table data
- Converting MYSQL to WordPress $WPDB
- Why is variable not working on custom sql query using wpdb?
- Show MySQL errors that occur when I excute $wpdb->insert()
- Can’t get wp_insert_post to work
- WSoD being caused by this piece of code
- I want to select the from values from database in WordPress? [closed]
- Update results, Before deleting the related category [closed]
- wp query foreach deleting record returning only first or last item
- Database query works fine outside WordPress
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- $wpdb->insert() does not Insert record in a table
- Help with a $wpdb MySQL Query
- Custom array from a query only write the last row of the query
- $wpdb returns duplicate posts
- Mixing variables into an array when inserting values
- Use $wpdb or other PHP script method to find/replace in WP database
- How can I add a new row in a separate database when someone registers via WordPress?
- Basic wpdb update question
- I can’t update my data through $wpdb
- Output: “Array”
- How to use mysql LIKE with wpdb?
- How do I prepare strings for insertions as values into a MySQL table?
- How to use AJAX in WordPress in MYSQL query?
- form $_post action value gets truncated after it passes through two forms
- Why won’t this wpdb get_results query return results?
- WPDB secure custom form
- Add row to custom database Table and delete all rows older than 1 day
- select a single val though a table in wordpress
- populate select options from extra mysql table data
- Query the links Database
- MySQL Query Returns Array () In Shortcode
- Passing in MySQL prepare statement parameter separately throwing error
- Convert a column of a table containing an Array as response in HTML
- Database SQL query error
- MYSQL TIMESTAMP when adding DATE_FORMAT then the output is blank, PHP conflict?
- Conditional formatting on data fetched from MYSQL
- What is the correct way to search 3 custom fields only in WordPress?
- Using wpdb to connect to a different database is not working
- Rewrite SQL query as a prepared statement and use in foreach loop
- Advanced WordPress SQL Query
- MySQL query in WordPress with AJAX
- Passed variable gets undefined variable error on insert on next page
- MySQL queries in WordPress
- Using the same shortcode to show any table from the database
- MySQL database migration to WordPress
- Error resetting database index using ALTER TABLE in $wpdb->query
- Putting form result in my database
- dbDelta support for FOREIGN KEY
- How to correctly submit a search form and display the result in an independent page
- Does WordPress cache get_user_meta() results?
- Using Echo in ShortCode – Stuck
- No wp-config.php file on local install of wordpress – site still displays
- Use ajax to update_post_meta
- What SQL / WordPress queries would need a nonce?
- Different database query in function.php using mysqli
- Call External Object in Class Function During Callback
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Create WP_Query to search for posts by their categories or their parent/child categories
- How to display data from custom table in wordpress phpmyadmin
- How WordPress reacts to a lack of memory of the server [closed]
- Replacing mysql_escape_string in a custom plugin when moving to PHP7
- Weird 404 URL Problem – domain name being placed at end of urls
- database sent to a JSON file
- WordPress SQL injection
- multiple where condition in result query
- Grouping posts by a custom meta value
- Can’t update multiple rows with $wpdb query
- wpdb prepare insert table doesn’t work
- Delete database record using plugin from admin panel
- Wpdb get->results to out the the month from the db
- Using wordpress function to retrieve data
- Live search from database table
- Why my query does not run with prepare
- wpdb getting avatars and author url
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- WordPress SQL JOIN query
- How to create Loop code for Menu using WordPress?
- How to WP_Query posts order by parent title?
- Error establishing a database connection (Set-up locally)
- how to get data from two different table from wordpress database
- Passing Current User ID into SQL statement
- How to insert multiple rows and columns in database using array
- Modify post image in full size
- Windows Setup: Error establishing a database connection
- WAMP SERVER Command Prompt SET PATH=%PATH%
- How can get all users by current user meta (array)?
- Processing forms with php to wordpress database
- How to fetch results from database
- How to connect database table to each registered wordpress user.
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- I am unable to fetch json data from wp_db
- How to send push notification in android using php? [closed]
- I have an error WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version
- SQL – How to echo out inside of where statement