Give your page wings: the WordPress Side Content Plugin

Technology Blog

I wrote this plugin to provide similar functionality to the Drupal Side Content module. It makes it easy to have unique sidebar content on any page. Yes, it gives your page wings – or its own widgets, anyway.

If you see any PHP errors on activating the plugin then the most likely cause is that you are using PHP 4. This plugin requires PHP 5.

Example of use: In the side bar for this article you can see an example widget the content of which was created using this plugin.

Download the plugin.

Here’s how to use it:

  1. Install and activate the plugin in the normal way.
  2. On the settings page for Side Content, enter the names for your widgets, one per line. (These will also be the names of your custom fields). Save your changes.
  3. On the Design->Widgets page, you’ll now see your widgets listed and you’ll be able to position them as you like in your sidebar(s).
  4. Edit a page (or post) for which you want one or more sidebar content widgets. The widget entry areas will be found in a sub panel headed “Side Content Widgets”. In each area enter the HTML (including any heading) you wish to appear. The widget content will be saved along with the rest of the page or post.
  5. Tip: use the HTML editor for the page to create content for a field, then (in HTML mode) cut and paste it into the custom field value area.
  6. Note: it now works with both pages and blog posts.
  7. Note: as of release 0.7 the plugin includes support for the new WordPress shortcode API.
  8. Note: as of release 0.6 the plugin is compatible with WordPress-MU.
  9. Note: as of release 0.5 it has its own subpanel on the edit page.

Although the plugin does not require any theme changes to be made, it does provide a useful API function that can be used in templates to adjust page layout if required. To call it, code as follows:


if(function_exists('the_side_content')) {
if(the_side_content()->has_widgets()) {
// template adjustments for side content widgets
}
// alternatively, you can test for a particular widget by name
if(the_side_content()->has_widgets('mywidget')) {
// template adjustments for side content widget 'mywidget'
}
}

Note that this plugin requires PHP5. Compatible with WP 2.5 through 2.8.1.

Download the plugin.

124 Responses to “Give your page wings: the WordPress Side Content Plugin”

  1. Dan Levy

    I’m going to install this tonight. Just what I was hoping WordPress would do themselves in an update. Great work.

  2. olivier

    very nice plugin indeed, hope it will include the posts too a day !
    I just have had a little problem with the doublequote (“) as they were escaped in the custom field when saved (\”). I used single ones (‘) instead and it did work properly

  3. Alfred Armstrong

    Olivier – I wonder how that happens. I suspect I’m missing one of wordpress’s magical calls that copes with all the different combinations of server variable set ups.

    The change to include posts is easy, so I’ll probably add it as an option in the next release.

  4. ryan

    Love the concept but afaird I just dont get it. I desparately want to have different widgets in the side bar of each page of my site.

    I followed the first steps and can see the
    “Side content widget: Stock Quote Sidebar” on the design, widgets page.

    But I dont get where to go from here? Everything I “add” would still appear on all pages?
    I’m not sure where exactly to enter the code (or what exactly is the code)

    Thanks for you help.

  5. Alfred Armstrong

    Ryan, so far you’ve created an empty widget. You can position it on the design widgets page, but nothing will actually appear until you give it some content.

    The way you give it content is as follows: edit a page or post then scroll down the page until you see the custom fields section. Click on it to open it.

    Ignore the pulldown on the left for now. In the key box enter the name of your widget EXACTLY as on the configuration page; in the value box enter the HTML you want for the widget content. Press ‘add’. (If there are quotes in the HTML you may find they’ve got \ characters in front – this is a wp 2.6 bug. In that case re-edit the html and press update for the field and all will be well.)

    Now save the page or post, and when you view it you should see the side content widget you defined, only on that page. Repeat for each post or page as required.

    One day I hope to have time to spend making the plugin a little easier to use, but don’t hold your breath!

  6. Jake

    Looks like a great plugin – just what I am looking for, except I get an error…

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /mnt/local/home/directory/example.com/wordpress/wp-content/plugins/side-content/side-content.php on line 18

  7. Jake

    Thanks for your help Alfred. I’ve upgraded from PHP 4.4 to 5.2 and the plugin is now working.

    Many thanks!

  8. Rob

    Hi, great plugin. I am using it with only 2 issues and not sure if you can help. I am displaying a side nav using ul and li tags – my links a href=”” etc etc, are always saving with backslashes =\”/link/”\. Ive used the HTML editor as you suggested. After removing the unnecessary slashes and saving the page again it works. Any idea why this is happening?

    Second thing is, any idea how to make the “value” input field bigger as the side content is quite long and hard to edit in the small input box. I suspect this is editing the actual WP page – did you have to do this, or attempt to do this?

    Thx

    Rob

  9. Alfred Armstrong

    Rob, thanks for the comment and glad you like the plugin. The slashes
    issue is a WP bug, I’m afraid.

    Regarding your other question, in a future version I mean to give the plugin its own edit area which should make life easier for anyone dealing with large chunks of HTML.

    Edit: From release 0.5 the new edit area has been added and the slashes error is no longer a problem.

  10. Alfred Armstrong

    Here’s a quick fix for the small boxes problem reported by Rob. Add the following to wp-admin.css:

    #postcustomstuff textarea {
    height:200px; /* adjust to suit your needs */
    }

    Edit: with the latest release the plugin has its own panel with larger input areas.

  11. dee

    I like the ideal of being able to add content. I follow the directions I think but got a weird looking layout on my widget screen after I put html in the same box that I named. Do you have simpler step by step instructions available for this plugin? I would really appreciate it! Thanks,

    Dee

  12. Will Castillo

    Hello,

    I wonder how can I add content to a widget using th API. I would loike to add the code in my template files. I know how to check if it has widgets or not, but I do not know how to set the content of the widget.

    Can you help me?

    Thanks in advance,
    Will

  13. Will Castillo

    Hey,

    I just want to let everyone know that I got a ultra-fast and very helpful reply via email to my previous question so I want to thanks Alfred for his plugin, his blog and now also for his support. Way to go!

    All best,
    Will

  14. sean

    Great except
    I can not get the post or page to save more than 1 widget (the last one) the others do not get saved.
    is this somehting obvious I am missing.

  15. Gary

    Dear Alfred,

    I am getting this error code when I try to activate the plug-in, can you help?

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /mnt/local/home/directory/example.com/wordpress/wp-content/plugins/side-content/side-content.php on line 18

    Thank You.

  16. Niraj

    I was looking forward to this plugin. However, it does not seem compatible with the Multi-User version of WordPress.

    http://mu.wordpress.org

    When I submit the names of the widgets in the Settings area, it shows me the “try again” screen.

  17. Vida

    I would love to use this plugin with my my WP MU. It’s an awesome idea and is very helpful.

    But when I try to add my widget lines it says: Are you sure you want to do this? Try again!

    Can you please help?
    Thank you so so much.
    Vida

  18. Tim Hall

    My side content widgets appear on my Widgets page, but when saving a post the side content doesn’t save, whether entered in the drop down box nor as a custom field. After saving it just disappears and the drop down box has closed and is empty. Any ideas? Thanks!

  19. Josh

    Hi Alfred,

    I’m getting the same error when activating in WP v263:

    Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /var/www/vhosts/example.com/httpdocs/wp-content/plugins/side-content/side-content.php on line 18

    Line 18 Code:

    private $widgets = array();

    Thanks for any help you can provide, and great work with this plugin — It’s a life saver, from one sidebar hardcode-er to another! 🙂

  20. Nirav

    Hi, i really want this plugin to work… but when i go to settings -> side content

    and enter the name of the widgets .. on clicking save i get the following error:

    “Are you sure you want to do this?

    Please try again.”

    Even if i try again ..the contents are not getting saved …any suggestions would really help

  21. Tracy

    Hi Alfred,

    Just what I’ve been looking for to use on school site I’m working on. I’m using WP 2.6.5. The template I’m using is widget ready and is already using a couple successfully.

    I’ve installed the side-content widget, activated it, made a widget title in the settings panel, added the widget to the sidebar in Design / Widgets – all without problems.

    However, like Tim above, even though I’ve entered some content in the Side Content field of a page and saved it (the page was an existing one), the side content widget is not displayed.

    I can’t see a response to Tim, so thought I’d give you another go.

    Thanks for your help in advance.

    Cheers, Tracy

  22. Tracy

    Hi,

    I should add that, like Tim, the content is not saved in the side content field after I press save.

    The field is not showing in the custom fields section.

    Cheers,

    Tracy

  23. pat

    Great plugin.
    Will it be updated for 2.7, I do not think it works out of box with 2.7 RC2.

  24. Steve

    This is a great plugin. Exactly what I’ve wanted. Just looking for some help. How can use it to pull an RSS feed? For our bio page, I want to have it pull the 5 most recent posts from blog of the staff person whose who is being displayed. Does that make sense?

    In short, what would be the call to display an RSS feed in this side content widget?

  25. Pat

    Thanks Alfred and look forward to the updates.
    You will know that 2.7 official does not allow your plugin to be activated.
    There are some other widget plugins, but none are as easy to effectively manage as your one.

    Steve you could use javascript or php to show rss feeds. You will need to do some research on what is best for you, maybe look up magpie.
    But I think Alfreds plugin is the best way to organise the show.

  26. hiran

    🙁 – doesn’t work on WP2.7, but tanks anyway…
    This will help me a lot

  27. Pat

    Have not tried it yet, if it works as before then it is the one of best plugins around.
    Wanted to say thanks Alfred for the work and a very happy Christmas and new year to you and yours.

  28. kchayka

    I just installed version 0.8 of this plugin in WP 2.7 and the 2 add-ons (NextGEN and qTranslate) are flagged as needing an upgrade from v 0.1 to 0.8. Can you please fix this in the released version? thanks

  29. Pat

    Alfred, Your plugin accepts and works great with html! is it possible to parse php. or maybe point me to how I could adapt it to do so.
    Aim-
    I would like one widget to show rss feeds, but differet ones on different pages and posts.
    Thanks

  30. chip

    Awesome Awesome Awesome. I’ve been through every widget changer out there for my 2.7 site and none of them worked. I’m not much of a programmer and just needed something to display different info for each page. You made it happen. I’ve been at this for hours now and I can finally get to work. thank you thank you thank you.

  31. Jesper

    Hi Alfred,
    Nice plugin, and I have got it working. But how do you exclude all the standard wordpress widgets from a page? I made a contact page, and the created contact widget sits nicely on top of the sidebar (and doesn’t show up anywhere else). But all the other widgets that are default in my design, e.g. categories, blogroll etc. are listed below. How to remove them from the contact page?

  32. Peter

    I have used in on a WP 2.6 installtion, and it worked really well (thanks for this solution). I’ve just upgarded to WP 2.7 latest release, but now I’m unable to add new items. I imagine this is due to the WP 2.7 upgrade. Will you be making a release for the latest WP versions? best regards.

  33. Wisam

    Two questions:
    1. How to make it work with qtranslate? I switched between languages and the side content kept the same content.
    2. How can I remove the rest of widgets from the side bar and keep only side content for that specific page?

    Thanks for the work!

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>