WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm very familiar creating page templates in WP and for this project I really just have one page template with an option to switch the sidebar from the right side to the left side. The problem is that I would hate to have all of that duplicate code in both templates especially since I'll just be swapping css classes on the two elements.


  • 2 separate Page templates
  • Custom fields
  • Custom taxonomies

I'm thinking that having a custom taxonomy might be the best solution. The client would see a small box on the right side of the page titled Visual Options and there would be a checkbox for Sidebar on right. It is intuitive and it is DRY.

Is there something else I didn't consider?

share|improve this question
up vote 1 down vote accepted

Don't use custom page templates for structural layout changes.

Use custom post metadata instead, and then output conditional CSS rules (or even custom HTML markup, though that's probably not necessary here) based on the value of the custom post metadata.

share|improve this answer
I was thinking about using custom fields (custom post meta data) but they seems a little less user friendly. Your thoughts? – BFTrick Aug 29 '12 at 18:38
Actually, using post custom metadata fits your description perfectly: "The client would see a small box on the right side of the page titled Visual Options and there would be a checkbox for Sidebar on right." That exactly describes the implementation of a post custom meta box. – Chip Bennett Aug 29 '12 at 18:50
Bennet My apologies. I thought custom fields & custom post meta data were the same thing. This is exactly what I was looking for! Thanks. – BFTrick Aug 30 '12 at 14:50

You can use conditional tags.

Example: Your index.php file in your currently active WordPress theme might look like this:


        // Home page
    } elseif(is_page('About Us')){
        // About Us page
    } else{
        // Any page
} elseif(is_404()){
    // Error not found page

share|improve this answer
This would work but there are a lot of pages and I would rather save this info in the DB rather than in the code. – BFTrick Aug 29 '12 at 18:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.