I can't find a way to place a div at the bottom of a wordpress sidebar, after all the widgets are displayed. Though I can acheive this by tweaking the themes I need a way to do this programmatically. Please help..

  • You are using which theme? – newuser Apr 2 '12 at 13:24
  • Are you wanting to do so programmatically, through functions.php, or directly, by opening the sidebar file, and hard-coding the DIV into place? – Sampson Apr 2 '12 at 13:24
  • Hi! @Jonathan Sampson, thanks for replying. Anything would do but I want it to be theme independent. – Tabrez Ahmed Apr 2 '12 at 13:26

You can use jQuery

$('<div id="your_div"></div>').insertAfter('#sidebar_container_id');


  • You are probably right for a single site installation. But a multisite would consist of different themes active at the same time. And all themes have a different #sidebar_container_id – Tabrez Ahmed Apr 2 '12 at 13:35
  • 1
    Than the best answer is Aram's. Either way you are still editing a file for each template. So, no matter how many templates you have, you would still have to edit each one. – Nick Apr 2 '12 at 13:49
  • 1
    Just an idea... Your plugin could hook into the get_sidebar and only echo jQuery. Then in the jQuery get the parent container and insert your div after that. – Nick Apr 2 '12 at 14:05
  • 1
    Your plugin could echo a blank div with an ID. Then use the jQuery to walk up the DOM from where it was inserted and get the parent container and then insert your div after that. That parent container doesn't need an ID, because you are referencing it from where your div was inserted. – Nick Apr 2 '12 at 14:23
  • 1
    echo <div id="your_plug_div></div> in your plugin then in the jQuery echoed from your plugin $('<div id="your_insert_div"></div>').insertAfter($('#your_plug_div').parent()); I think this will get you started. – Nick Apr 2 '12 at 14:29

You could probably hook into an action which prints the sidebar, and then print something after it. See the Actions API. dynamic_sidebar and get_sidebar might be useful.

  • I tried that. But get_sidebar calls the callback just before sidebar is started to display. – Tabrez Ahmed Apr 2 '12 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.