Most websites have a main content area which is composed of more than a single content block.
As WordPress is first and foremost a blogging platform, its support for a highly flexible CMS isn't comprehensive. This is mainly seen in the pages feature of WP, where each page has a single editable content area. This is useful only for single content block layouts, and complex websites aren't based on such layouts.
Take the case of a layout having a header, content, right area, left area, footer section etc. There are several methods to make each section dynamic within the same page. One such method is by using Categories & Posts feature of WordPress.
Home Page
Steps for creating a dynamic page
- Create a page template : Create a template file say, “home.php” in your “/wp-content/themes/yourtheme directory”.
- Create the page : Create a page without any content and assign the template created in the above step to the page.
- Create category : Create a category for each section in the layout. For example, referring to the above image, create “Header” category for header contents, “Left-Content” category for left block contents, etc.
- Create posts : Create content for each section using posts. For example, say the header section has a logo and a mission/vision text. Create a post having a title, say, “Header-Logo” and paste the logo image in the content area. Then assign the category “Header” to this post. Similarly a post title “Header-Text” can be created. You must note the “PostID” of each post you are creating.
After creating all the posts(content) for a particular page, you need to retrieve the post contents in your template file(home.php) created in the first step. For this, use the code below :
For the header section :
For the left content section :
Similarly retrieve content for right-section and footer area.
Drawback
The only difficulty with this method is with your site's blog functionality. Blog index page will show all the posts created irrespective of the categories. So if you are implementing a blog in your site, you must exclude the categories created for adding page contents from the list of blogs. Otherwise all posts in those categories will also be indexed in your blog page.
How to exclude multiple categories from blog pages (index.php, single.php, search.php, archive.php, etc)?
Use the code :





