Home » Php » php – How to make long time process in wordpress backend?

php – How to make long time process in wordpress backend?

Posted by: admin February 25, 2020 Leave a comment

Questions:

I created a plug-in to automatically add posts.

But when adding 100 posts, only 18 will be added.

I think that’s a matter of timeout.

So I added the next line.

set_time_limit(0);

But the results are the same.

My code is as follows.

Please help a lot.

Thank you.

<?php

    require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );
    require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/wp-db.php' ); 

    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);


    global $wpdb;

    foreach ($playlist_id_array as $key => $playlist_id) {

               ~ ~ ~

                while(true){

                  ~ ~ ~

                    if($clip_time == 10 || $j >= 997){

                        ~ ~ ~

                        $postID = wp_insert_post($post_dup, $error);


                    }

                }

    }
How to&Answers: