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 using WP as a CMS, not a blog. I have a lot of pages (not posts) that need to have different content per page in the sidebar. The content (html, images, php) in the sidebar will be different depending on what page you are viewing.

Since I have a lot of pages, I don't think checking for what page is currently displayed and then show a different template part/widget in sidebar based on that check is feasible. Otherwise, I would have tons of is_page() calls. Right?

What other options do I have? I looked around for ways to add multiple WYSIWYG editors to a Page's editor mode, but it looks like is not possible without a plug-in which I don't want to add.

What about multiple Text widgets? I guess I can create as many different widgets as I need for the sidebar, but how do I specify the widgets I want to use on a specific page.? It would great if you could, in Page editor mode, select the widget(s) you want to use just like you can select the page template to use.

I'm not great at PHP, so what's the best, quickest, code-less way to do what I need without a plug-in.? The reason I don't want to use a plug-in is to keep down the code weight, and the widgets I did look at to solve my problem seemed "wonky".

I'm using the latest version of WP.

share|improve this question
one of those without a plugin questions.....there is no such thing as code weight, theme code === plugin code. – Wyck Jan 15 '13 at 17:35
All I meant was this: I don't want to add a bunch of plug-in code to my theme, if possible. – Mark Bubel Jan 15 '13 at 18:10
up vote 1 down vote accepted

Add a metabox to your post type, see this answer for details. In you sidebar look for the post meta key _t5_extra_box and display its content if it is available.

But … I would do this in a plugin and move the rendering into a widget. This is about content mostly, so it doesn’t really belong to a theme.

share|improve this answer
This seems to add it to the Post editor page, not the Page editor page. – Mark Bubel Jan 15 '13 at 16:38
Well, you have to change it a little bit, of course. :) Use add_meta_boxes_page, not add_meta_boxes_post as hook. – toscho Jan 15 '13 at 16:47
Right, yea not good at PHP at all. Okay, I have the metabox displayed, and when I try to add content to it and save it, the page refreshes with no content in the metabox. Not sure what's wrong. Sorry - this is with no experience in this part of WP. – Mark Bubel Jan 15 '13 at 17:05
You have to replace post with page where you need it, or 'post' !== $_POST['post_type'] for example with or 'page' !== $_POST['post_type']. – toscho Jan 15 '13 at 17:30
Ok, I think I finally got this to work. I check for that post meta key and display the contents if not empty. Whatever I type is the metabox does indeed display in my sidebar. I didn't actually use the short code [extra] though. It doesn't seem to matter if I add it to the editor box or not; the meta data still displays. Do I need to worry about this? – Mark Bubel Jan 15 '13 at 18:07

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.