How to divide your WordPress blog into two or more different main pages.

I have a self-hosted WordPress blog. How do I divide my blog into two different main pages for posts that belong to two different contents?


First thing to do is to create two main categories for your post: category A and category B. (You can create sub-categories that belong to these two main categories.)

The next step is to configure your blog so that all the posts that belong to category B will be displayed on its own main page (mainpage-B), and the rest of the posts (which belong to category A) will be displayed the other main page (mainpage-A).

Usually a blog has a home page (which isn’t necessarily the “Home” page of your blog website, that could be any page chosen by you) where it displays all the latest posts chronically. This page is configured by the template index.php (or sometimes it is home.php) located in your theme folder (blog/wp-content/themes/your_theme_folder/).

In the above scenario, this home page would be mainpage-A. So what you need to do is to exclude all the posts that belong to category B from being displayed on the mainpage-A, and include all these posts on mainpage-B. This can be achieved by some PHP coding.

Here are the detailed steps:
1. Create two main pages for your blog: mainpage-A and mainpage-B. Point your blog’s home page to mainpage-A (in the blog’s admin panel, go to Settings/Reading/ Front page displays: A static page / Posts page: from drop-down menu choose mainpage-A). This page now should display all your latest posts chronically.

1. Create two main categories A and B for your posts.

2. Exclude category B’s posts from the blog’s home page (mainpage-A):
Install SimplyExclude plugin for WordPress. Enable the plugin for your blog. In the blog’s admin panel, go to Settings/Simply Exclude:

Action Name: Front – Description: Visibility on the front/main page. – Inclusion/Exclusion: Exclude (checked).

ID: # – Category Name: B – Exclude from…: Front (checked).

Note: front/main page here is your blog’s home page. What you’ve done is to exclude category B from being visible on the home page. Also note the ID # of category B that is shown on the Simply Exclude screen (here we suppose that the ID# is 2).

3. Include category B on mainpage-B:
Open your index.php (I use TextWrangler to do this as modifications can be saved directly to my FTP/SFTP server), save as second_index.php

Edit second_index.php by replacing the first line of the regular loop, which is something like:

with this line
< ?php query_posts(‘cat=2&showposts;=10‘); ?>

Note: 2 is the ID# of category B, and 10 is the maximum number of posts displayed on on mainpage-B (you can change this number to anything you want).

Also, change the name of this new template to “Second index page” by placing at the top these code:
< ?php /*
Template Name: Second index page

Finally, apply the template second_index.php for your mainpage-B (in the blog’s admin panel, go to Pages, edit mainpage-B, from Template drop-down menu choose Second index page.

4. That’s all! You now have the mainpage-B display the posts from category B, and mainpage-A display the rest.

Note: You may notice that on mainpage-B, the tag to display partial posts becomes ineffective. Apparently this is default behavior (for good reason) on pages.

You can fix this problem by declaring a variable named $more as a global and set it to false right before showing your content. If you wish to resume normal behavior after the content is shown, simply set the variable back to true.

< ?php
/* This line of code to make the More tag work in this page by change the global variable $more to false */
global $more; $more = false;

More code here….

< ?php

/* Return the global variable $more to true */

$more = true;

%d bloggers like this: