Inserting editable text in the sidebar
Update: since I wrote this post, I discovered some problems with this solution. I ended up using a different solution, which you can see in Inserting editable text in the sidebar – part II: Widgets.
I created a site for a client based on WordPress that needed some dynamic editable text in the sidebar aside from the usual blog-type stuff like archives and categories. They had a section they needed to be able to update frequently and easily from the backend.
First I tried to use Kaf’s Get-a-Post plugin. I put the required code in the sidebar, and the owners of the site could edit the specified post and the updated content would appear on the site. But the plugin did weird stuff to the text that appeared under that part on the sidebar. It was creating links where there shouldn’t be links, and was changing the formatting of the h2′s.
Next I tried Kaf’s Welcome Visitor plugin. This creates a new link under Options in the backend, and on that page you can enter text in what is very similar to the regular WordPress Write Post or Write Pages format. On this Welcome page you can enter a title and text, and after putting the correct code on the sidebar (or wherever you want it to appear), that text and changes you make to it appear there. But this plugin had even more quirks: the Welcome link under Options only appeared to users with administrative privileges, and not to anyone else; and it disappeared on the front end to any users that are logged in to the site. So I ruled this one out too.
And then I found the answer: Improved Include Page plugin. I created a page with the name that should appear as the header on the sidebar. I made sure to code the header so that this page wouldn’t appear on the navigation bar by entering the following code where the navigation bar should appear:
<?php wp_list_pages('exclude=12&sort_column=menu_order&title_li='); ?>
12 is the page ID, and the “exclude” code tells the page not to display that particular page name in the navigation bar.
Then I put the following code in the sidebar where I wanted the text on that page to appear:
<?php if(function_exists('iinclude_page')) iinclude_page(12,'displayTitle=true&titleBefore=<h2>'); ?>
Now this code tells the page to display the Page with ID of 12.
Title=true means it will display the title of the page, and
titleBefore=<h2> means that the title will be styled with h2 tags.
And it worked! You can see the results here: www.kayema.com. Look at the top text on the sidebar, where it says “KSI Quote” – that header plus the numbers and date underneath are editable in the backend on the page called “KSI quote.”