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?
Leave a Reply
You must be logged in to post a comment.
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 thenhave_posts()
,query_posts()
,the_content()
and so on to display it within the template files (e.g. probablyfooter.php
in your case).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.
There are several ways to do that:
Options 1,2 can be implemented using query_posts.
Option 3 can be foind here