It would be safer to use [wp_insert_comment()][1]
rather than manually through MySQL. WP often inserts data in multiple tables – using its core functions helps ensure that all of the data gets added in all of the right tables.
I’d suggest creating a query to pull all published posts. Then, set up a foreach loop that calls wp_insert_comment()
on every post, thus inserting the comment on each one.
Related Posts:
- How to properly insert data into custom table via plugin
- How to display results from a data table with an encrypted user id?
- add_action for publish_post doesn’t work
- Cant create table on plugin activation
- Moving a few select DB tables to a new WP instance
- How does WordPress handle MySQL row lock errors?
- Simple form that saves to database
- Searching users with WP_List_Table plugin
- How to store ACF custom fields data in a custom table
- Can I explicitly specify ENGINE=InnoDB in WordPress?
- Bad Request (Invalid Hostname) on working server, database problem
- Changing BIGINT to INT
- How to edit/delete single row items in a table on my own menu page
- greatest() function returns undefined property
- Get total number of comment of the posts written by an author
- Make id column as AUTO INCREMENT on plugin activation
- How to get number of Affected rows from wordpress dbDelta() function
- How to determine what is generating large amount of database queries?
- Display data on Word Press site posts and pages from mysql table
- How to access data in wordpress database externally using php
- How to simultaneously access the same MySQL database in the main column and sidebar of WordPress?
- Help With MySQL to WPDB Query Conversion
- WpDataTables – View Image Directory
- How can I perform high-level database merging for WordPress within continues delivery?
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- WordPress Backend HA (Automatic failover)
- Automatic switch to backup database on fail
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- Multiple instance of data in plugin custom database table on plugin activation
- Better ads plugin has 500.000 entries in wp_postmeta
- Creating a CSV with PHP inside the plugin directory
- pagination on data fetched using SQL query
- after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()
- Notice: Uninitialized string offset: 0 in social sharing mu-plugin
- Issue running db create table query from static method
- dbDelta not adding additional columns in plugin database update
- Using ‘mysqli_connect’ ‘crashes’ WordPress client-side
- Always get creating a new table with foreign key
- How to do database for download stats?
- How to create plugin/ page that reads from database
- How can I fetch data from another website to my wordpress website with mysql database
- DB Query not working in Plugin
- External wpdb connections in different plugins on single page
- speed up pagination for huge database
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- Way to send multiple values for column to MySQL?
- WordPress plugin: efficient way to store large data
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]
- Is this plugin safe to run?
- Integrating Custom Database with WordPress
- Check against server time to display SQL entries – Radio Station DJ Rotator Plugin
- WordPress Cache delete on plugin uninstall
- Getting URL GET parameter with Code snippets and storing it in database?
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Getting current user data with MySQL statement
- How to get the custom field value using SQL query
- What database state changes happen after a post is manually “updated” with no changes?
- WP Function does not trigger on Webhook API Call
- How to get database connection details without longing to cpanel in WordPress?
- Performing CRUD operations on front end in wordpress
- How to use WordPress header function and footer function and not load word press database
- Get Shortcode output to database for static post_content
- Store GravityForm data in phpmyadmin (mysql)
- WordPress database problem wp_posts, primary key
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- How can I store user preferences in WordPress and retreive them later?
- get/show Last ID
- HyperDB failover Delay
- Write mysql credentials in plugin
- How to save information related to post in database?
- MySql Query for WordPress
- how to search through plugin in wordpress cimy-user-extra-fields?
- How can I delete the options from DB when the plugin is deleted?
- PHP Creating a formula from mysql db values and db stored math operator
- Split Million WordPress Post’s Into Multiple Database Server
- Getting 504 Gateway Timeout Error on AWS Server! [closed]
- WordPress issue – data is not showing in wp-admin, but when searching through database, all the data is there
- plugin doesn’t retrieve data from database
- if plugin is active? check if plugin is enabled or not?
- Making plugin unique to not conflict with plugins with the same name
- Default Plugin Settings Not Writing to Database
- Custom Post Type Plugin not loading category template and loading 404 instead
- WP plugins for building a database?
- How to insert HTML/JavaScript form into WordPress page? [closed]
- How to check if a taxonomy not exists in a plugin
- wordpress add_action() issue in ajax call
- Send email with list of active plugins upon activation/deactivation
- Strange admin-ajax / CSS / $_SESSION issue
- How to create admin setting for this small plugin
- $wpdb->delete not working for me
- Post source link plugin – small modification
- How to securely controlling data without keeping it in postmeta?
- Block plugin update possibilities (but not by hiding notifications)
- Soflyy WP All Import Custom File Download Issue
- Displaying friend’s posts only
- MySQL database migration to WordPress
- Option value not getting updated until page refresh in WordPress
- Fatal error: Uncaught Error: Call to a member function fetch_array() on bool
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class