Give your page wings: the WordPress Side Content Plugin

Friday, July 4th, 2008

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.

You can see it in action on our starter site package page. The three blocks in the righthand sidebar belong to this page and only appear on it. (Our custom theme uses the API functions that come with the plugin to detect the widgets are there and show them in an extra wide sidebar.)

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

Download the plugin.

Share this post: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Technorati
  • del.icio.us
  • StumbleUpon
  • Facebook
  • Sphinn
  • TwitThis

Sign up to our newsletter for great WordPress and Drupal tips.

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

  1. baron Says:

    hi. Thanks for plugin

    perfect.

    Regards

  2. Flick Says:

    Sounds brilliant! :D Thank you! No more messing about with multiple sidebars!

  3. Alfred Armstrong Says:

    Thanks! Feel free to rate the plugin on wordpress.org: http://wordpress.org/extend/plugins/side-content/

  4. Dan Levy Says:

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

  5. olivier Says:

    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

  6. Alfred Armstrong Says:

    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.

  7. Philix Says:

    This is a great plugin

  8. ryan Says:

    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.

  9. Alfred Armstrong Says:

    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!

  10. Jake Says:

    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

  11. Jake Says:

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

    Many thanks!

  12. Rob Says:

    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

  13. Alfred Armstrong Says:

    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.

  14. Alfred Armstrong Says:

    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.

  15. dee Says:

    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

  16. Will Castillo Says:

    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

  17. Will Castillo Says:

    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

  18. sean Says:

    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.

  19. Gary Says:

    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.

  20. Niraj Says:

    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.

  21. Vida Says:

    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

  22. Tim Hall Says:

    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!

  23. Josh Says:

    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! :-)

  24. Alfred Armstrong Says:

    Josh, the PHP error is due to you running under PHP4. Please note that PHP4 is not supported.

  25. Nirav Says:

    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

  26. Alfred Armstrong Says:

    For Nirav and others using WordPress MU, the latest release includes the necessary magic code required for MU compatibility.

  27. aslifm Says:

    Very Nice plugin perfect for me thanx

  28. Tracy Says:

    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

  29. Tracy Says:

    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

  30. Alfred Armstrong Says:

    Tracy, the latest version of Side Content should fix the problem, I think.

  31. Time Synchronisation Says:

    This is a great plugin

  32. pat Says:

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

  33. Alfred Armstrong Says:

    Pat, I’ll update the plugin as needed once 2.7 is released.

  34. Steve Says:

    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?

  35. Pat Says:

    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.

  36. hiran Says:

    :( - doesn’t work on WP2.7, but tanks anyway…
    This will help me a lot

  37. Alfred Armstrong Says:

    As of today there’s a new release which works with WordPress 2.7.

  38. Pat Says:

    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.

  39. Alfred Armstrong Says:

    Thanks Pat. All the best to you and anyone else reading this.

  40. hiran Says:

    Working perfect with wp2.7
    thankyou Alfred

    happy new year…

  41. kchayka Says:

    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

  42. Pat Says:

    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

  43. chip Says:

    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.

  44. Alfred Armstrong Says:

    Glad to be of service, Chip!

  45. Jesper Says:

    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?

  46. Alfred Armstrong Says:

    Jesper, there’s a great plugin called Widget Logic which solves this problem: http://wordpress.org/extend/plugins/widget-logic/. You’ll need to code some very simple PHP to make it work but the examples are helpful.

  47. Jesper Says:

    Thanks! Tested and works!

  48. Peter Says:

    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.

  49. Wisam Says:

    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!

  50. Thiet ke website Says:

    Thanks a lot for sharing this plugin.i love it’s functionality.

    have a good day

  51. FendyBt2 Says:

    This is the one that I’ve been looking for… Thanks!
    But it can’t exec PHP code :(
    It would be nice if you could make it so that it could exec PHP code like the ExecPHP plugins… ;)
    Anyway… great plugins!

  52. Gosia Says:

    This plugin is great. Thank you.
    If it was possible to run PHP it would make it perfect.
    Thank a lot

  53. Alfred Armstrong Says:

    I’ve now had a couple of requests to make the plugin execute PHP, but my feeling is that if that’s what you think you need, you are probably after a different plugin, and chances are it’s Widget Logic.

    http://wordpress.org/extend/plugins/widget-logic/

    Having potentially different PHP scripts on every post is a maintenance nightmare and in my view a Very Bad Idea.

  54. darya Says:

    This is almost exactly what I want, but I want different content for category pages, not individual posts and pages. Is there a way for this to work for me?

  55. John Says:

    Ajax movable and WYSIWYG-editor would kill. :)

  56. Pete Hawkins Says:

    Is there any reason why this widget would not allow a libghtbox effect to work? I’ve placed different next-gen galleries in different pages and the effect isn’t working…. can let you have the url (privately) if you wish as it’s in a testing environment and not fully operational yet. Cheers

  57. Alfred Armstrong Says:

    Pete, I took a look at your page and it would seem to be the theme at fault: no javascript being loaded.

  58. Adfer Says:

    Doesn’t work on WP2.7.1, but tanks anyway

  59. Adfer Says:

    Wooww, Side Content 0.8 yes works in WP2.7.1 !!!

  60. Jarvis88 Says:

    Hi,

    The plugin looks very useful!! thanx!! Just one question, it cant remove the sidebar completely from certain pages can it??

    If not, do you know what I could use for this?

    Thanks

  61. Alfred Armstrong Says:

    Jarvis88, it’s not suited to that problem: usually I’d solve it by creating an alternative page template. See http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates for more details on how to do this.

  62. Casey Says:

    I’m excited to get this plugin to work. I think it is exactly what I am looking for. However I am new to WordPress and can’t seem to figure out how to get it to work.

    I have activated the plug-in. It appears on my “available widgets” list but for some reason the name of the widget is blank and only the description “Side content widget:” appears. Is that normal?

    I added the custom field at the bottom of my page, but I am confused as to what the “value” is supposed to be. Also, can I designate which side the content appears on? Thanks for helping out a “newbie”

  63. Wordpress als CMS « augenschoner Says:

    [...] hatte zunächst noch das PlugIn Side Content installiert. Über dieses PlugIn kann man Boxen erzeugen, die dann im Bearbeitungsmodus direkt [...]

  64. Martin Says:

    Great and very usefull plugin! Thank you!!!

  65. WordPress 插件集锦系列 151-200套 « wordpress 非官方中文站——助力中文wordpress Says:

    [...] Side Content Plugin [...]

  66. Rob Says:

    Hi Alfred,

    great plugin. Ive emailed you a few times about it and thanks for the support. Just a question to get your thoughts as I have a need for a new site and want to use your plugin. The issue is I have a sidebar using your plugin being shared on 3 pages of the site. If the sidebar content is updated, it must be updated on all 3 pages, something I want the site owner to avoid doing. can you see anyway so that if the sidebar content on one page was updated it would automatically be updated on all 3 pages? Can you see anyway to get this work?

    Thanks

    Rob

  67. Michael Says:

    hi alfred,

    i guess i have php 4, b/c i received the fatal error when activating plug message. i guess my question is, how to do i update to php5? and will this mess up my other sites?

    thanks,

    michael

  68. Give your page wings: the WordPress Side Content Plugin | Likemind Web Services | Squico Says:

    [...] Go to Source [...]

  69. Aaron Says:

    Hi, I just downloaded and installed your plugin but it does not seem to be working correctly on WP 2.8. On the Edit Post page, the widget textboxes are there, but there’s nothing in the right column next to them– I didn’t even know there was supposed to be anything there until I saw your 7/31/08 comment above. Any idea how to get this to work, or do you plan to update it to work with 2.8?
    Thanks,
    Aaron

  70. Adrian Says:

    This is a great plugin thank you so much.
    It worked perfect.

  71. Jeremy Says:

    Does Side Content work with Word Press 2.7 or 2.8. I have tried the plugin in both versions but everytime I add the custom field and save the post the custom field disappears. Any other custom field I enter works and saves with no problem.

Leave a Reply