Categories
24 Days of WordPress Tutorials

Day 19: Creating a Blog Within a WordPress Site

One of the great advantages of working with WordPress is that it has a blogging platform built right in. Some would argue that this is because WordPress is a blogging platform but I disagree. WordPress is a content management system that in its past used to be a blogging platform. But that’s and argument that is a total waste of time. The only thing that really matters is this: You can use WordPress to build a site with multiple posts, categories and other content and still have a blog inside it. And on this 19th Day of WordPress I’ll show you how.

What do you mean “a blog inside it”?

Let me explain myself here so it’s clear what I’m talking about. Imagine you are building a site for an illustrator. The site has four static pages (front page, about page, CV, and contact) and she also has a series of posts stored under categories including portfolio, articles and tutorials, each with sub-categories. But in addition to these non-blog posts she wants a section on her site called “blog” where she can post all the stuff that doesn’t fit anywhere else.

To get all this to work we need to set up a new category called “Blog” with however many sub-categories she wants, create a page called “Blog” on which to display the blog index page and finally limit the posts displayed on the blog page to only posts listed under the Blog category or its children. So let’s get started.

Setting it up

Logged into WordPress create a new page called Blog. Don’t put any content in the page as it will be used as the blog index page.

With the new Blog page published go to Settings -> Reading, set Front page displays to A static page and select your home page (whatever it is) as your Front page and the Blog page as the Posts page (remember to hit Save Changes).
Changing the front page of a WordPress site

Displaying only posts from the Blog category

To get WordPress to only display posts from the Blog category on the blog index page you need to add a query to the index.php file. The query first checks if this is indeed the blog page (is_home) and then restricts the posts displayed only to those posts in the Blog category (using the slug “blog”) or its children:


If you want to use the category ID instead you can do so by changing the variable in the query like this (assuming the category ID in question is 3):


The query_posts() function has a lot of varialbes and there are tons of cool things you can do with it so I recommend checking out the WordPress Codex page for the function as a way to expand your coding horizons.

This tutorial is part of the 24 Days of WordPress series. If you want to learn more about WordPress and Expression Web check out the Sams Teach Yourself Microsoft Expression Web in 24 Hours series (version 2, 3 and 4), Lynda.com’s WordPress 3.0 Essential Training course and Microsoft Expression Web 4 LiveLessons.

By Morten Rand-Hendriksen

Morten Rand-Hendriksen is a staff author at LinkedIn Learning and lynda.com specializing in WordPress and web design and development and an instructor at Emily Carr University of Art and Design. He is a popular speaker and educator on all things design, web standards and open source. As the owner and Web Head at Pink & Yellow Media, a boutique style digital media company in Burnaby, BC, Canada, he has created WordPress-based web solutions for multi-national companies, political parties, banks, and small businesses and bloggers alike. He also contributes to the local WordPress community by organizing Meetups and WordCamps.

10 replies on “Day 19: Creating a Blog Within a WordPress Site”

Will this work with WordPress Multisite enabled?

I’m working on a project where there is a main site (powered by WordPress) with multiple child sites (maindomain.com/childsites). I know I can also install WP in /childsites to power those child sites, but I need to have a separate blog section in each child site.

Thanks!

Does this work on wordpress MU, and also what the current index page will display when we set front page posts to created category?

someone reply please…

Do there any plugins for members to post in to blog and maintain the posts that they were posted?

anyone suggest me a plugin if it is there..

thanks in advance

“Creating a Blog Within a WordPress Site” was actually pleasurable and informative!
Within modern world that’s challenging to carry out. Many
thanks, Reagan

Hi! I have just discovered these tuts, they’re great! I am working on a local site with mamp to eventually upload it. I have used this tutorial to achieve precisely as described, but when it comes to previous-next navigation there is something wrong.

The blog page will only display the latest 20 posts, but when I hit “Previous” at the bottom it goes to mysite/blog/page/2 but keeps displaying the latest 20 posts. What am I doing wrong?

thanks a lot in advance!

Comments are closed.