Mike Meisner

I create attractive and functional websites

Posted by Mike
November - 8 - 2009

Conditional PHP statements can be your best friend when developing for WordPress. They allow you to display information based on certain conditions. We can use WordPress’ internal meta data, such as tags and categories, to determine what to display in certain cases. In this case, we want to simply display a unique heading for various categories.

In your category.php page you’ll want to paste this code snippet:

Here’s a quick snippet of code that allows you to include any number of different headings using one category page. Of course, adjust the category id to your own.

<h1>Classifieds</h1>
<?php } elseif is_category('4')) { ?>
<h1>Environment & Real Estate</h1>
<?php } elseif is_category('18')) { ?>
<h1>Hot Buzz</h1>
<?php } elseif is_category('16')) { ?>
<h1>Product Plaza</h1>
<?php } elseif is_category('7')) { ?>
<h1>Menu Development</h1>
<?php } else { ?>

This is a basic, but powerful idea. You can use “elseif has_tag(’tagname here’))” to do the same thing with tags instead of categories for instance.

Related posts:

  1. Deliver targeted ads to visitors using WordPress This is the Targeted Ads Approach Wouldn’t it be...
  2. WordPress SEO Trick – Optimize “Read More” Link I’m going to share a simple snippet of code that...

Related posts brought to you by Yet Another Related Posts Plugin.

Leave a Reply

About Me

I am currently available for hire. If you need a basic website or a fully functional CMS for your business, I can help. I'm also pretty good with the whole marketing and SEO side of things and offer services in those areas as well.

Flickr

wineme2sonomasilverado