More than one page with posts – WordPress

Let’s pretend we have just created our dream site based on WordPress CMS and we have a craving for multiple subpages on our homepage, where our posts will be displayed, just like on We already dug through the whole Internet and we still don’t know how to do it. Here I am going to describe the simpliest way how to do it.

A short intro

In this method, the choice of posts which will be displayed on the given page is provided by categories. Our subpage with posts is simply a page of a given category and all posts which we would like to show on this subpage must be binded to the category. We will fiddle around with PHP. All of the discussed files are located in the main folder of our actual theme.

Let’s roll!

To begin with, create a new category in the WordPress Admin Panel. In my case, it would be “Category”. Now we will need a file called category.php. If our theme doesn’t utilize one, create it. category.php is responsible for the appearance of categories page. Then, locate home.php, and if you can’t find one, locate index.php, which keeps the information about the look of our startpage. That’s exactly what we need for our subpage to look like our homepage, so let’s copy the content of home/index.php to the category.php, overwriting everything that’s inside. And that’s it! But what to do if we want to change the appearance of only one category page? We must create a file category-name_of_the_category.php. Instead of name_of_the_category we enter a simplified name of our category or the category ID. A “category.php” can be freely modified in any way you want, you just need to know what you’re doing.

That’s basically everything, now all you have to do is to enter your Admin Panel and add to your blog menu a link to the category. In the blink of an eye we added our category subpage. If you want to know more, you’ll find WordPress Codex Category Templates.

Wait a moment! I don’t want my subpage posts to be displayed on my startpage! What should we do?

Locate the file functions.php and add this at the bottom of the text file:

 add_action('wp_head', 'iworks_only_one_category');
function iworks_only_one_category()
    if ( is_home() || is_front_page() ) {
        global $wp_query;

Instead of ID enter the ID of the category you wanted to get rid of or present on your homepage. When we add a “-” prefix before the ID, this category won’t be shown on the startpage, and if you enter your ID without the minus, only this category will be displayed. You can find your category ID in the URL, during editing of the category or with use of plugin of some kind.

That’s all folks!

More than one page with posts – WordPress
Bądź pierwszy i oceń!

No Comments

Leave a Reply



Ile jest * Time limit is exhausted. Please reload CAPTCHA.


This site uses cookies to store information on your computer. Click for more details

Our site uses cookies to personalise site content and advertisement, to offer social network functions and to analyse traffic on our website. Information we gather about using our website are shared with our social media, advertisement and analytical partners. You can find more info on How Google uses data when you use our partners' sites or apps.