How to add one time a new page?

If this code is in functions.php or directly in plugin code, the for loop at the top will run every time WordPress is loaded, and the hook at the end refers to a function which doesn’t exist.

So probably what you want is to put the top code in a function:

function zed93_create_new_page {
    for ($i = 0; $i < count($namepages); $i++) {
        mic_create_new_page($name[$i],$namepages[$i]);    
    }
}

And correct your hook to:

register_activation_hook(__FILE__, 'zed93_create_new_page');

Note the function name can be anything, but making it unique to your project helps avoid collisions with other plugins / themes.

Leave a Comment

error code: 523