Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'jnews_single_post_after_content', 'add_post' );
- function add_post() {
- global $wpdb;
- $post_count = 100000;
- $chunk_size = 10000; // Adjust the chunk size as needed
- for ( $i = 0; $i < $post_count; $i += $chunk_size ) {
- $posts = array();
- for ( $j = 0; $j < $chunk_size; $j++ ) {
- // $post = array(
- // 'post_title' => 'Dummy Post ' . ( $i + $j ),
- // 'post_content' => 'This is dummy content for post ' . ( $i + $j ),
- // 'post_status' => 'publish',
- // 'post_author' => 1, // Adjust the author ID as needed
- // 'post_type' => 'post',
- // );
- $postname = 'dummy-post-name-dummy-dummy' . ( $i + $j );
- $posts[] = '(\'Dummy Post ' . ( $i + $j ) . '\',\'This is dummy content for post ' . ( $i + $j ) . '\',\'publish\',' . 1 . ',\'post\',\'' . current_time( 'mysql' ) . '\',\'' . $postname . '\')';
- }
- $query = "INSERT INTO {$wpdb->posts} (post_title, post_content, post_status, post_author, post_type ,post_date ,post_name) VALUES " . implode( ',', $posts );
- $wpdb->query( $query );
- // error_log( $query );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement