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?
- dbDelta only creates the last table
- WP JSON REST API (Ryan McCue) how to query posts with specific meta data with ‘AND’ relation?
- Creating two database tables via plugin
- Query Posts by Custom Field ‘Price’
- WP_query parameters for date range
- insert data in database table from plugin with WP3.1
- Is their any way to Extend WPDB class and Overwrite the Default Query Function
- 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
- ob_end_flush error when using wpdb in plugin
- Thumb rating for wordpress – top user
- Show the “ratingValue” and “ratingCount” values of KK Star Ratings Plugin
- Updating post meta for custom post types
- Find out if request is for custom post type archive before query runs
- How to extract images of post and pages excluding header and logo image in wordpress?
- How can I add a custom meta value on file upload?
- $wpdb->get_results() does not fetch results with unicode ‘WHERE’ clause
- post_content getting cut off on blank space on $wpdb->update
- How to count number of records found in a database table?
- How to get custom field image url of specific size
- Fatal error: Uncaught Error: Call to undefined function get_userdata()
- 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?
- Set attached to state
- How to change ID of an attachment in wp_posts and its related tables correctly?
- Add multiple attributes to product from php
- How use %like% in sql statement wordpress
- 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
- WordPress logo upload option in theme panel
- Accessing GET variable named ‘error’
- Select from wp_post and multiple meta_value from wp_postmeta
- Inserting large amounts of data into a custom table during plugin install
- WP_Query ordering numbers as letters
- FacetWP group listings by custom field [closed]
- Where to hook my plugin’s action
- plugin ajax to external php file always return null
- Is there a filter for get_post_custom()?
- How can i list random post from multiple category?
- how do i remove posts from a WP_Query so the pagination is right?
- dynamically generating plugin syntax
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Accessing post’s meta data based on user’s click of a post
- When to call add_filter
- WooCommerce shop page orderby [closed]
- w3 total cache and post__not_in
- WP_Query Date Filtering Inclusive Being Ignored
- Proper way to trigger a MySQL query via link in a plugin
- Second foreach loop breaking (Posts2Posts)
- Advanced Custom Fields (ACF) Plugin – Random Image in Sidebar
- Ger posts from similar tags and categories
- get_var result empty for query of custom table in plugin admin
- wp_query for more fields plugin
- Storing values in Post Meta vs new tables
- WordPress filter function using query modifications
- wpdb get_var is not returning any result (verified mysql query returns only one value)
- WP-Snap too slow (caused by WP_Query?)
- WordPress Meta Query: Relation is not working correctly
- WordPress ultra slow if I click on posts?
- Insert data in custom table during new post creation
- Making a Custom Post Type Publish Loop
- Include subtitle display to slideshow
- Checking url from plugin [duplicate]
- Add meta tags with a plugin?
- Making plugin to use different table prefix cause permission problem
- WordPress User Frontend Editing Custom Fields
- wordpress last all added get meta value by post id
- 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]
- getting image alt text via ACF plugin in WordPress [closed]
- Get all the related data from WordPress DB
- $wpdb selects wrong database
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- FATAL ERROR: WP complains about redeclaration [closed]
- Update post meta Rest Api
- how to add meta for order in woocommerce
- I want to display data last 7 days with date wise in chartjs?
- 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
- wp db request without refreshing the page
- What is the easiest way to create a custom field archive?
- How to disable Yoast meta description for all pages
- WP_Query does not return the result even if the data is present in the database
- Show the author only own types of publications. (JetEngine, Elementor)
- Force post update with React
- How to filter posts with a wp query by a custom dropdown type field with the magic fields plugin
- How to create a dynamically created page on wordpress plugin?