How to create a live demo page for a theme? [closed]

This is how I would do it in a plugin:

  1. Install WordPress as a multisite with subdomains.

  2. Use the main site for the theme shop, install Easy Digital Downloads or another shop plugin. Create a product for each theme, make sure the slug matches the theme directory name.

  3. Upload your themes.

  4. Write an empty function wp_install_defaults() to prevent the default content in new sites.

  5. Add the test data from wptest.io to your plugin. They are better than the WordPress theme test data.

  6. Hook into wpmu_new_blog and check if the site slug matches an existing theme. Then:

    • Install the test data.
    • Set the option blog_public to FALSE to prevent search engines from indexing your test data.
    • Create or update a site option with an array containing the site ID, the theme slug and the visible theme name that you get from the style.css.
    • Activate the matching theme.
    • Create a sticky post from the content of the style.css and add a Buy now! link that goes to the product on the main site with a matching slug.
  7. Force the admin bar to be visible on all sites, even when the user is not logged in. Add a menu that is fed from the site option and build a list of all theme preview sites. You can also use a widget for that.

  8. Filter the product page on the main site and add a link to the demo site with the information from the site option.

There are probably many details that I missed here, but as a basic concept, this should work fine.

Leave a Comment