running two separate blogs in one wordpress instance (part 2)

So now that you have your his/her blogs located on separate pages, how do you display the latest posts for each blog?

create home page template

We’re going to create another page template just like we did in part 1. I’m calling my file home_template.php and naming it “Home Template”. Here is my file header.

[php wraplines="false"]
<?php
/**
* @package WordPress
* @subpackage Napkin_Theme
*
* Template Name: Home Template
*/
[/php]

Now let’s get to the code.

[php]
<?php query_posts ( ‘meta_key=blizzog&meta_value=hers&showposts=5′ ); ?>
<?php if ( have_posts() ) : the_post();?>
<!– featured article displayed here –>

<?php while ( have_posts() ) : the_post(); ?>
<!–recent articles displayed here –>
<?php endwhile;?>
<?php endif; ?>
[/php]

Line 1 contains the all-important post query. Here you can see we’re grabbing all posts with a meta_key of blizzog and meta_value of hers. We’re also using showposts to limit the number of posts to 5. Of course, to grab his posts we’ll simply change the meta_value to his.

From this point, you should be able to use the Loop to display articles in whatever way you please. However, lines 2-8 show the skeleton for my Napkin theme where I use jQuery to transition between featured and recent articles. I’ll expound upon this in part 3.

create a home page

Nothing crazy here, just hit the “Add New” link under Pages and label it appropriately. Then select the proper template as I explained in part 1 and save. We’ll probably want to make this our home page so click the “Reading” link under the “Settings” menu. Select the “A static page” radio button and set the “Front page” drop-down to the appropriate page.

If you have any questions, please leave them in the comments section. Until next time!

Tags: , ,

One Response to “running two separate blogs in one wordpress instance (part 2)”

  1. [...] part 2, we’ll look at how to display recent posts from both blogs on your homepage as seen in the [...]

Leave a Reply