• My theme doesn’t support sidebar widgets, and I’ve widgetised it using the help on the Automattic site.

    Now I can use my Dashboard to go to the Sidebar Widgets section, which shows the box ready for me to drag widgets to. But my current sidebar (which is created in the index.php file) already has items in that I want to keep – for example the calendar, links that I’ve updated, feeds and MyBlogLog stuff.

    Do I need to move the entries from my index.php into a sidebar.php (my theme didn’t have one of those, either), so the sidebar is loaded from the sidebar file rather than being embedded in the index.php? If so, how do I tell the index.php to load the sidebar.php?

    TIA
    Sorry for these questions – my php is almost non-existent, I’m only used to plain HTML and CSS. ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    It’s hard to say exactly what you need to do without looking at the code.

    I recommend moving all the existing sidebar content you have into widgets. For some of the sidebar content, this is easy. For other content, it’s not as easy. There’s two resources that can help with this:

    https://widgets.wordpress.com has a big list of widgets, some of which may help to replicate your sidebar content in widget format.

    And my plugin, ExecPHP adds a widget which will run PHP code. So you can move the remaining custom bits of your sidebar into widgets easily. For just straight HTML code, you can stick that in a normal Text Widget instead, no need for the PHP widget.

    As for your index.php vs. sidebar.php, your index.php file should have a call to “get_sidebar()” in it somewhere. This is what calls the sidebar.php file.

    Thread Starter pramclub

    (@pramclub)

    Thanks for that. Now I have a really silly question. How do I tell what’s a widget? I’ve added two, which were called widgets, but are javascript. I downloaded a sample widget from the WordPress widgets site that you mentioned, and that’s php.

    So when is a widget not a widget?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    A “widget” in the sense of a WordPress Widget is a PHP file containing one (or more) widgets. Always. It will be in the form of a plugin which you must install and activate. To install it, you put the PHP file in the plugins directory, and then you activate the plugin on the Plugins screen. Then the widget will be available for you to drag and drop. Complex plugins may be more complex than that.

    Javascript cannot be a widget. Not in the WordPress Widgets sense of the word. You could paste the javascript into a Text Widget and thus put the javascript on your page, though. But useless javascript on the page is generally a bad idea, as it makes your page slow and take longer to load.

    You could always make your javascript into a plugin widget. It’s not hard to do.

    Thread Starter pramclub

    (@pramclub)

    golddave, could you give me a link to read about that, please?

    otto42, I have alternative widgets for everything I want now – but the css is built on nested ULs (the link colours and backgrounds change according to how “deep” the LI is nested). I assume that this won’t work if I’m using a widgetised sidebar?

    (My host has chosen this week to have major downtime problems, so I can’t play about with it as I’d like to!)

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    It should work with a widgetized sidebar. I’m not understanding why it wouldn’t. Of course, you will have to tell the sidebar to use UL’s and such for wrapping the sidebar pieces, but that’s easy enough.

    Look at any page that describes how to write a plugin. Or you can send me the javascript coder and I could put together a plugin for you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Widgetising a theme’ is closed to new replies.