elegant themes

Inserting editable text in the sidebar

| March 20, 2007 | 6 Comments

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.”

Improved Include Page>>

Tags: ,

Category: Plugins, WordPress as CMS

Comments (6)

Trackback URL | Comments RSS Feed

  1. Alpesh Nakar says:

    I would really to see dynamic update using this plugin. Pulling my shared feeds from Google, so that I don’t have to write or share cool links from others via a post.

    Any ideas?


  2. Miriam says:

    Hey Alpesh,

    I don’t use Google Reader (I am a big fan of Netvibes), so I don’t know much about their shared feeds feature. But if your shared feeds page has an RSS feed, than it is possible to set up your blog to display RSS feeds from other sites. Actually, there is a newish site called Dapper (set up by Israelis – a national plug!) that allows you to “RSSify any site”, so even if Google Reader doesn’t provide a built in RSS feed for your shared page, you may be able to create one.

    I will write about displaying RSS feeds on ablog soon (so stay tuned), and if I have time I’ll test out Dapper and see if I can get it to display an RSS-type feed on WordPress from a site without RSS. It’s an interesting question that you’ve asked, and I’m excited to see what we discover!

  3. Miriam says:

    Alpesh, I think I have found something that might help you with putting your shared items from Google Reader. Take a look at elifoner.com. Click on any of the items, and you will see that in his sidebar he has a box that displays items from his Shared Items in Google Reader. If you click on Read More… in the box, it takes you to his Shared Items page. It looks like you can subscribe to his feed there. This means that you probably have a feed for your shared items too. So all you have to do is display the feed for your shared items in your sidebar. How do you display feeds? That’s another question, and I hope to discuss that here soon…

  4. Ryan says:

    Awesome! This is exactly what I needed :)

    It would be nice if it added an ‘edit’ button to the page though. Miriam, if you know how to add this I’d love to hear about it. Otherwise I’ll have a hunt round and see what I can dredge up.

  5. Miriam says:

    Ryan – I ended up having trouble with this method. See what the problem was, and how I ended up solving it: Inserting editable text in the sidebar – part II: Widgets

  6. Ryan says:

    Yeah I saw that post as well. But those issues shouldn’t be a problem for what I’m trying to do. It’s working perfectly for me so far.

Leave a Reply

If you want a picture to show with your comment, go get a Gravatar.

More in Plugins, WordPress as CMS (89 of 132 articles)