New Template Blog - working on dev, not prod

I'm trying to push my new multi-site to production, but my new blogs don't have copied content, plugins, or settings. It really just isn't doing it's job. I'm sure that I either have a missing setting or a subtle conflict.

* I've tried resetting the 'default' template
* I've looked at the db, and the tables are there
* I've tried a full plugin delete and reinstall
* I've tried making it only copy plugins, settings, and menu
* I've tried force the user to pick a template

All of the above has the same results, with the new blog being a generic install with the sample page.

I'm otherwise willing to dig into the code, but it would help to have a starting point.

Any hints as to what to look for?

If it helps, I'm hosting at

  • Michelle Shull

    Hey there, jjroher!

    I'm guessing you're having a timeout issue, if you're seeing templates stop copying. Are you dev and production environments both on WP Engine? Is it their staging site setup where you can import the settings from staging to pro?

    If it's not a timeout, I would suspect one of the pieces of content/data/what-have-you you're trying to copy is corrupt, and causing the process to hang.

    I've got New Blog Templates running great on my multisite with ProSites and a bunch of other plugins active, so I don't think the issue is necessarily on our end.

    Let's do some quick troubleshooting for a conflict, first. Try creating a vanilla subsite with an image or two uploaded to the media library, and a couple of posts/pages. Don't include any plugins at this time. Try creating a template from this vanilla site, then try to select it when creating a new site.

    If it works, we know that you're either
    1. Timing out on memory during the process.
    2. Faced with a bit of wonky content that's throwing a wrench in your gears.

    For the first issue, you can try one of the following options to increase your memory limit:

    In wp.config, edit the existing memory limit or add this line:
    define('WP_MEMORY_LIMIT', '128M');

    If you can access the php.ini file on your server, you can edit the PHP memory limit by changing this line:

    memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)

    If you can not access this file, you can try adding this line to your .htaccess file:

    php_value memory_limit 64M

    For the second issue, the tests are sadly going to be more trial and error. You're already on the right track by trying to copy limited options, but I think you'll need to do more toggling things on and off to find out what in particular is causing the problem here.

    Hope this helps!

  • jjrohrer

    Thanks @Michelle Shull for the well thought out response.

    I _think_ I've figured it out. I hope this can help the next person. I had a plugin, that because of debug statements, sometimes generated some non-fatal output on activation. It seems that that this state causes New Blog Templates to default to generic worldpress install.

    I haven't had the chance to reproduce the problem, but this is my latest theory (after spending waaay too much time narrowing down when the problem got introduced).

    To future readers: If this seems to apply to you, and quieting your output solves your problem, please make a note here to help others.
    Also, I found the plugin "Debug "unexpected output" During Plugin Activation" very helpful.
    Lastly, my next wish is to catch this bug(?). If the template can't be created, defaulting to a blank wordpress installation in not acceptable, at least not in my case.

    Thanks for the help, and good luck.

  • jjrohrer

    Update: I totally did not figure it before, but I think I have it figured out this time. Probably.

    I use a callback to track my blog lineage. Something like this:

    add_filter('blog_templates-blog_template', 'track_templates', 20, 3);
    function track_templates($template, $blog_id, $user_id) {
        $parent_id = $template['blog_id'];
        $asrLineage = buildAncestorTree($blog_id, $parent_id, [],$template);
        update_blog_option($blog_id, 'asrLineage', $asrLineage);
        return $template; //<-- super important to return this!

    That last line is really needed in order for the template to process. Now, the funny thing is, I was not returning $template, and it _sometimes_ worked. Go figure - probably some priority condition. Looking at the blog template code, it absolutely needs that $template var returned. My only question now is why it ever worked?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.