开发者

WordPress: How can I create two blogs sharing the same database?

开发者 https://www.devze.com 2023-01-29 08:01 出处:网络
I\'ve built a WordPress website at e.g. domain.com and I\'m wanting to build a Web App at e.g. chrome.domain.com which will contain a second installation of WordPress but the site will be exactly the

I've built a WordPress website at e.g. domain.com and I'm wanting to build a Web App at e.g. chrome.domain.com which will contain a second installation of WordPress but the site will be exactly the same in terms of content (except for the URLs) and have a different theme.

Is it possible to do this? Any suggestions on how I could do this? Perhaps somehow running a different theme for the app on the main web开发者_如何学JAVAsite? As I'm also looking to make the site work on both the iPhone and iPad again with Themes for each so as to make it all look native.

Thoughts on this would be much appreciated. Thanks.


I would suggest you to make use of WPMU, which now is Network in the latest wordpress release. What this does is to allow you to use a single install of wordpress as one or more wordpress blogs. You can then just use a theme and tell wordpress to display what is on main wordpress blog on this blog.

Using the above strategy, will make you utilize a single database for all your wordpress blogs (called as network blogs) and also help in making them talk to each other (e.g. here you want the chrome.domain.com blog to display posts from domain.com blog)

A more detailed information can be found at: Create a Network

To display posts from main blog (which is generally id= 1), use a function like:
(the below function is just an example) in your chrom.domain.com theme's template file

function get_recent_blogposts_wpmu($blog_id,$show){
 wp_reset_query();
 switch_to_blog($blog_id);
 global $post;?>
 <?php $my_query = new WP_Query('showposts='.$show.'&order=DSC');
 while ($my_query->have_posts()) : $my_query->the_post();
     $do_not_duplicate = $post->ID; ?>
     <li class="post_link"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> </li>
        <div style="float:left;margin:5px 0 0 10px;">
        <?php the_content(); ?>
        </div>
 <?php endwhile; ?>
 <?php restore_current_blog();
}


If you can leverage CSS for all of the different environments, you could use javascript to load the environment/theme-specific CSS.


I would just pull in an RSS feed from your main site and use that as displayed content on your sub-installations. You might start by looking here: http://wordpress.org/extend/plugins/feedwordpress/

0

精彩评论

暂无评论...
验证码 换一张
取 消