You can’t insert multiple rows via wpdb’s insert, you have to do it with raw SQL:
INSERT into $meta_table (post_id, meta_key, meta_value)
VALUES
('val1', 'val2', 'val3'),
('otherval1', 'otherval2', 'otherval3')
However-
You should always use the API where a function exists- use add_post_meta so your plugin integrates with the WordPress environment and its behavior can be modified without having to edit the plugin’s files directly.
Related Posts:
- Comparisson between date() and a date from wp_postmeta
- any word search WordPress
- How to securely controlling data without keeping it in postmeta?
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- How to fix slow comment query?
- Action hook “wp_insert_post” works but not for last imported post
- How to delete all records from or empty a custom database table?
- Update Multiple Post Meta for the Same Post In One call?
- Stackoverflow type of badge plugin giving warnings in WordPress 3.5
- Missing argument 2 for wpdb::prepare() Issue
- Find out if request is for custom post type archive before query runs
- How can I add a custom meta value on file upload?
- How to count number of records found in a database table?
- How to get custom field image url of specific size
- Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
- Advanced Custom Fields query
- How do I add advanced custom fields / meta fields to Elasticsearch? [closed]
- Can I run multiple queries with $wpdb->prepare?
- How to change ID of an attachment in wp_posts and its related tables correctly?
- Add multiple attributes to product from php
- Why am i getting this error? WordPress database error: [Query was empty]
- Make the checkbox meta field checked by default
- medoo framework in WP plugin
- Accessing GET variable named ‘error’
- Select from wp_post and multiple meta_value from wp_postmeta
- WP_Query ordering numbers as letters
- plugin ajax to external php file always return null
- How can i list random post from multiple category?
- dynamically generating plugin syntax
- When to call add_filter
- WooCommerce shop page orderby [closed]
- How do I “get the next 10 posts after post_id == x”?
- Correct way to perform non-cacheable DB query
- AJAX search posts and pages
- What is generating my meta og:description?
- Creating mySQL procedure with $wpdb
- DROP TABLE with uninstall hook not working
- Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
- get current date + 90 days and checking every day
- WordPress Post Visibility Options for Frontend
- How to create a custom shortcode based on the layout?
- Bulk update all posts from plugin settings screen
- plugin code is pulling information from database in one instance and not in other. What is wrong?
- ACF: post query, hide duplicate values [closed]
- Mass SQL WordPress Meta Key deletion
- WordPress query posts with multiple post_meta data
- order posts by `meta_key`, Does not display posts that does not have `meta_key`
- Date format – Meta Box plugin
- get meta value from database by post id
- Replacing global wp_query
- How to select a paragraph other than the 1st to be the post’s excerpt?
- How can I concatenate variables to search results title? [closed]
- woocommerce search by sku and title ajax
- Mowing site to another domain in simplest way
- BuddyPress activity on edit post for a CPT
- Remember the Meta Value With Radio Buttons
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]
- Link Posts to External URL
- Adding CASE in WP_Query
- Need help creating asynchronous data scraper in WordPress
- Woo-commerce Update price as a Bulk from My offline software export
- Trying to get property ‘ID’ of non-object in /wp-includes/class-wp-query.php on line 4044
- how to display recent post by category on home page
- How to fetch WordPress database values in JavaScript widget
- get_post_meta shortcode returns empty field
- $wpdb->delete not working for me
- Add an action based on custom post meta field
- Warning: call_user_func_array() problem can anyone help with it?
- how to auto random increment for post view
- How to get a specific string from a url
- Using id to show item
- WooCommerce Product Table – filter query on attributes
- How to pass multiple custom fields as shortcode’s parameters
- Is it possible to custom set query for a WordPress REST API response?
- How to create meta fields with more than 1 relation?
- How to get post that has non zero or greater than zero meta value
- Delete postmeta when uninstall/delete plugin
- How to insert variable which contain array value in wp_options table?
- Trending Tags based on post views
- Shortcode in a blog post, footer and related products stop working
- How to delete only user meta value (not key) from usermeta table in wordpress?
- How can i see/log all requests coming from a registration form (not from the UI)?
- Write mysql credentials in plugin
- w3 total cache and post__not_in
- WP_Query Date Filtering Inclusive Being Ignored
- Advanced Custom Fields (ACF) Plugin – Random Image in Sidebar
- get_var result empty for query of custom table in plugin admin
- Making a Custom Post Type Publish Loop
- Add meta tags with a plugin?
- WordPress User Frontend Editing Custom Fields
- Get post id in Post Page within Wp-admin
- Is it safe to increase/alter the size of the wp_post.guid column from VARCHAR(255) to VARCHAR(2048)?
- Output plugin post like system count [closed]
- $wpdb selects wrong database
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- how to add meta for order in woocommerce
- How to check record is exist or not in WordPress CRUD Operation with $wpdb
- Order custom post type by posts with most likes first
- Accessing Correct Database to Create REST API Endpoint
- How to filter posts with a wp query by a custom dropdown type field with the magic fields plugin