This is a guest post by Muhammad Siyab.
WordPress is a very flexible and versatile blogging platform, and can be adapted for use as almost anything (CMS. Tumblelog, etc). In this post, I’ll be telling you how to make your WordPress blog more ‘magazine style’. You will learn how to include post-thumbnails, how to display specific posts on the homepage, automatically update a page which contains posts from a certain category, and more.
Using if/else to check for pages
You can use conditional tags such as if/else to check which page the user is currently on and what content to display to them. The basic structure goes like this:
/* If the page is NOT the specified one */
Using conditional tags will make your sidebar dynamic and alive. It is good to have a dynamic sidebar that displays information according to the particular page.
Let’s put this into action. Suppose, you want to display your work details and testimonials to the reader, if they are on the About page of your blog. Else, (if they are not on the about page), you want to display your most recent posts. The code to do the job would look like:
--YOUR WORK DETAILS AND TESTIMONIALS HERE -- --MOST RECENT POSTS CODE HERE --
What the above piece of code does is that it checks first what page the current page is. If the current page has the exact title ‘About Me’, then your work and testimonial details are shown. If the page is not the about page, your most recent posts are shown. Note that the title of the page(’About Me’) in this code and the about page must match exactly, otherwise the code will not work.
You can view all the applicable conditionals on the WordPress Codex.
Automatically Update Pages
Suppose you have a page in which you show whole posts or link to posts in a certain category. Each time you write a new post, you manually enter the information into the page. This is tedious and time consuming. You can, instead have those pages automatically updated for you! The code to use is:
Leave a Reply