How to create a live demo page for a theme? [closed]
IT Nursery
May 7, 2022
0
How can you create a live demo page for a theme ?
something like a wordpress theme showcase, allowing customers to preview a specific theme live before they decide to purchase.
I have seen this on studiopress for example or any major theme seller.
Example.com – main website
Example.com/theme1/ – displays a demo of a certain theme
example.com/theme2/ – another theme, ETC
Can this be done with a plugin? Or do you have a better idea perhaps multisite?
Thank you
1 Answer 1
This is how I would do it in a plugin:
Install WordPress as a multisite with subdomains.
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.
Upload your themes.
Write an empty function wp_install_defaults() to prevent the default content in new sites.
Add the test data from wptest.io to your plugin. They are better than the WordPress theme test data.
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.
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.
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.