• I’m sorry, I speak a little English.

    The first 25 posts is uploaded, but have a 400 post.

    What is the problem?

    The source code:

    foreach( videos( $_POST [ 'profile_id' ], $url ) as $key=> $video ) {
    
    	$args = array(
    
    		'post_status'=> 'publish',
    		'post_type'=> 'post',
    		'meta_key'=> 'video_id',
    		'meta_value'=> $video [ 'id' ]
    
    	);
    
    	$the_query = new WP_Query( $args );
    
    	if ( $the_query->have_posts() ) {} else {
    
    		$postarr = array(
    
    			'post_title'=> $video [ 'title' ],
    			'post_status'=> 'publish',
    			'meta_input'=> array(
    
    				'video_id'=> $video [ 'id' ],
    				'thumb'=> $video [ 'thumb' ],
    				'video_url'=> $video [ 'url' ],
    				'video_preview'=> $video [ 'video_preview' ],
    				'price'=> $video [ 'price' ],
    				'duration'=> $video [ 'duration' ],
    				'profile_id'=> $profile_id
    
    			)
    
    		);
    
    		wp_insert_post( $postarr );
    
    	}
    
    	wp_reset_postdata();
    
    }

    Thanks.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You may have hit the execution time limit. Writing DB records is a relatively slow process. You could extend the allotted time with something like
    @ini_set('max_execution_time', 480 ); //default 30
    added to wp-config.php. It’s not good to leave this at a long period of time. If there should be a coding error, it’ll take that long to recover.

    A better option is to break up the insertions into manageable chunks. You could schedule a task to run every few minutes to add another chunk until all posts have been inserted.

    Yet another option is to compile the data into a file format compatible with importing via phpMYAdmin app. Good knowledge of SQL and WordPress data schema is needed to accomplish this option.

    FYI, we have support forums in many different languages if you prefer to converse in your native language. However, it’s likely many more people will see your post in these “International” forums. In fact, English is not required here. You may post in your preferred language. Most of us would then rely upon machine translation to understand what you say. Machine translation may not do the best job, but it’s often adequate for us in general to understand your question.

    • This reply was modified 3 years, 6 months ago by bcworkz. Reason: added link
Viewing 1 replies (of 1 total)
  • The topic ‘wp_insert_post limit 25’ is closed to new replies.