Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

migrated from stackoverflow.com Apr 2 '12 at 13:29

This question came from our site for professional and enthusiast programmers.

    
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? –  Jonathan 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
add comment

2 Answers 2

up vote 1 down vote accepted

You can use jQuery

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

Documentation

share|improve this answer
    
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
show 3 more comments

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.

share|improve this answer
    
I tried that. But get_sidebar calls the callback just before sidebar is started to display. –  Tabrez Ahmed Apr 2 '12 at 13:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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