Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress - display specific widget

Tags:

I'm lost a bit.

Let's say I have a dynmic footer-siderbar. Easy so far.

<footer>     <?php get_sidebar("name") ?>   </footer> 

Displys it in the footer.

But here we are. I want EACH widget inside of my grid:

      <footer>          <div style="width: 100px:">             <div style="width: 25%">First widget here</div>             <div style="width: 25%">Second widget here<</div>             <div style="width: 25%">Third widget here<</div>             <div style="width: 25%">Fourth widget here<</div>           </div>         </footer> 

So get_sidebar isn't an option now, since it displays all widgets in a row. And I don't want to edit widgets itself.

How they do that in themes?

Thanks.

like image 981
fomicz Avatar asked Nov 18 '10 12:11

fomicz


People also ask

How do I show widgets on a specific page in WordPress?

Install and activate the plugin. Navigate to Appearance, then to Widgets. Click the Set Visibility button and choose the pages where you want your widgets to be displayed.

How do I display custom widgets?

Using WordPress Custom WidgetGo to the Appearance menu, and select Widgets. You should see a widget named Hostinger Sample Widget in the Available Widgets list. Next, drag the widget and drop it in the Sidebar section on the right side of the page. Save your changes and visit your website.


2 Answers

You can use the 'the_widget' function for this:

<?php the_widget($widget, $instance, $args); ?> 

More information can be found on the Wordpress Codex - The_Widget reference.

like image 112
Rhapsody Avatar answered Dec 01 '22 00:12

Rhapsody


This is a good reference as well - Function Reference/dynamic sidebar « WordPress Codex

If you use the method on that page:

<ul id="sidebar">  <?php if ( !dynamic_sidebar() ) : ?>     <li>{static sidebar item 1}</li>     <li>{static sidebar item 2}</li>  <?php endif; ?>  </ul> 

You could then use CSS styling to position the sidebar widgets across the footer.

Edit to include the following...

Arras theme CSS:

#footer             { margin: 20px auto 0; width: 980px; background: #ECEBE6; padding-bottom: 10px; border: 1px solid #CCC; } #footer .widgetcontainer    { padding: 5px 10px; min-width: 150px; } .no-js #footer .widgetcontainer { height: 190px; } #footer .widgettitle    { background: none; border: none; font-size: 14px; color: #444; padding: 0 0 10px; letter-spacing: -1px; } #footer .widgetcontent  { font-size: 12px; background: none; padding: 0; border: none; } #footer .footer-message { margin: 0; padding: 10px 15px 0; font-size: 11px; } #footer .footer-message p { margin: 0 0 0.5em; } #footer .footer-message .floatright { margin-left: 20px; } #footer-sidebar     { overflow: hidden; margin: 10px 10px 0; padding: 0 0 10px; border-bottom: 1px solid #CCC; } #footer-sidebar .widgetcontainer    { float: left; margin: 0; max-width: 250px; } #footer-sidebar ul  { list-style: none; margin: 0; padding: 0; } #footer-sidebar li  { margin: 0 0 3px; } 

Footer coding:

<ul id="footer-sidebar" class="clearfix xoxo">         <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer') ) : ?>         <li></li>     <?php endif; ?> </ul> 

In the theme it then places the widgets across the page.

like image 27
Vince P Avatar answered Nov 30 '22 23:11

Vince P