Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sometimes it might be necessary to include frequently-changing content in a theme, but themes take some time to modify, it may also be necessary to let a non-technical user maintain some content that appears on more than one page. Is it possible (without heavily impacting performance) to include a post in a theme?

alt text

share|improve this question
    
Would it be possible for you to expand/clarify your question? Perhaps word it differently? –  tnorthcutt Aug 24 '10 at 3:27
    
Agreed with @tnorthcutt. Frankly, I have no idea what you are asking; please clarify. –  MikeSchinkel Aug 24 '10 at 6:28
    
I've added an example image. –  Gelatin Aug 24 '10 at 10:55
add comment

3 Answers

up vote 2 down vote accepted

You can but I think it's far more easier for you theme to add a sidebar and then place a text-widget (or any other widget) inside there because that's far more flexible.

What you describe I did for some sites longer ago. You can just load the post and display it. I used query_posts() to get the post(s) and then have_posts(), query_posts(), the_content() and so on to display it within the template files (e.g. probably footer.php in your case).

share|improve this answer
    
Do you have a link explaining some of these concepts? As I understand it, sidebar is totally misnamed - it's actually a generic placeholder for content. Is that correct? What's the 'text-widget' stuff all about? I've never come across 'widgets' in wordpress before. Thanks. –  Bobby Jack Aug 25 '10 at 12:01
    
Themes do offer so called "Sidebars", that are generally spoken container boxes widgets can be placed into. Widgets are just boxes again which can contain different functinality, e.g. your latest posts listing, comments, tags and free-text. The later one is called Text-Widget. You can configure Widgets by Drag and Drop in the Admin: Appearance -> Widgets. This Menu Entry is only available if the currently active theme supports Widgets. Test with the default theme for example. codex.wordpress.org/WordPress_Widgets#Using_Text_Widgets –  hakre Aug 25 '10 at 15:39
add comment

You should definitely use a widget to achieve this functionality, rather than hardcoding a call to a particular post in your theme. There are plugins that extend the widget functionality and make it easy to control which pages the widgets appear on.

share|improve this answer
    
If you're worried about the hardcoded call in the template, how about including the post by one of the other, many fields - e.g. tags? I've had this exact problem and, to be honest, I DID just hardcode the call in the template - this isn't a public theme that will ever be reused, so I see no downside to that approach. –  Bobby Jack Aug 25 '10 at 11:59
    
In terms of future maintenance (i.e. possibly for other people, besides the asker), using a widget is much clearer as far as what's happening, where the content displayed on the page is coming from, etc. –  tnorthcutt Aug 25 '10 at 17:56
add comment

There are several ways to do that:

  1. Include a page (that does not appear in the menu)
  2. Include a post
  3. Add an option page to the theme, this page will include the text field you need here.

Options 1,2 can be implemented using query_posts. Option 3 can be foind here

share|improve this answer
add comment

Your Answer

 
discard

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.