0

I have a wordpress multisite for a bunch of friends of mine. And every time I create a new blog there are a few things I have to do before I can give it to them.

  • Activate a new plugin
  • Create a new page with a specific title

I am wondering if there is and kind of script i can record to make this happen. I.e. in MS Office there is a way to record makros which will record what you do and then repeat it.

Is there something similar in wordpress?

0

WordPress has no macros like that but it can be done.

If the plugin is already installed, you can Network Activate it so it will be available on any blog in the network.

As for the page with title, you'll need to create or source a plugin to do that as it will need to be created after the site is created.

A quick and untested approach:

add_action( 'wpmu_new_blog', 'wpse_190815');

function wpse_190815( $blog_id ) {
    $page_title = 'Custom Page Title';

    $post_data = array(
        'post_type'  => 'page',
        'post_title' => $page_title,
    );

    //switch to the new blog
    switch_to_blog( $blog_id );

    //create the new page
    $page = wp_insert_post( $post_data );

    //go back to the current blog
    restore_current_blog();

}

This should probably go in wp-content/mu-plugins to be sure it's always loaded.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.