php - How to add wordpress widget widget to static Sidebar via code? -


i'm making wordpress site, , have static sidebar, , wondering how add plugin widget said sidebar. here sidebar code:

<div id="sidebar">     <div class="sidebar-entry sidebar-both">             <ul>              <?php the_widget( 'wp_widget_search' ); ?>           </ul>     </div>      <div class="sidebar-entry sidebar-left">             <h2> <?php _e('categoies'); ?></h2>         <ul>             <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>         </ul>     </div>     <div class="sidebar-entry sidebar-right">            <h2> <?php _e('archives'); ?></h2>         <ul>             <?php wp_get_archives('type=monthly'); ?>         </ul>     </div>      <div class="sidebar-entry sidebar-right">            <ul>             <?php the_widget( 'wp_widget_meta' ); ?>           </ul>     </div> </div> 

first can make widget area in theme adding code in functions.php file

if ( function_exists('register_sidebar') ) register_sidebar(array(     'name'=> 'custom sidebar',     'id' => 'custom_sidebar',     'before_widget' => '<li id="%1$s" class="widget %2$s">',     'after_widget' => '</li>',     'before_title' => '<h3>',     'after_title' => '</h3>',     )); 

now have widget area 'custom sidebar' in appearance->widget

now drag widget in area , access in custom sidebar, call dynamic_sidebar() id as:

<?php dynamic_sidebar('custom_sidebar'); ?> 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -