I am developing a theme in which I want to call available widgets ex. Calendar and the installed plugin, I have put it in the sidebar from widget panel but can't see in frontend.

Sidebar.php Code->

<div id="sidebar">

<h2>News & Announcements</h2>

<ul class="sidebar_list">

<?php dynamic_sidebar('sidebar'); ?>
You can color this theme as you wish, by its powerful theme options panel. It has great      documentation.<br /><br /><br />

<?php if (is_page(array('home', 'about-us', 'academics', 'admission', 'activities',  'hall-of-fame', 'alumni', 'photo-gallery', 'news' ))) ?>
<?php $menu=wp_nav_menu('menu=sidebar_menu'); ?>
<?php if ( ! dynamic_sidebar( 'Sidebar' )) : ?>
<?php //If dynamic sidebar not found show the default widgets  ?>
<?php endif; ?>


functions.php Code->


// Sidebar Widget

I will put a basic code to create new widget. In WordPress its call register_sidebar; In your code, you have not put ID. Id=>your-widget-id

Put this code into your functions.php

function my_widget(){
    register_sidebar( array(
        'name' => __( 'Front Sidebar', 'yourtheme' ),
        'id' => 'sidebar-1',
        'description' => __( 'This is description', 'yourtheme' ),
        'before_widget' => '<aside>',
        'after_widget' => '</aside>',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
    ) );
add_action( 'widgets_init', 'my_widget' );

then put this code in your index.php or sidebar.php (wherever you want)

if ( is_active_sidebar( 'sidebar-1' ) ) : //check the sidebar if used.
dynamic_sidebar( 'sidebar-1' );  // show the sidebar.

Remember to put the ID.

More http://codex.wordpress.org/Function_Reference/register_sidebar

  • I have to paste this as it is: Id=>your-widget-id or specify the id number also?? – admin Jan 10 '14 at 10:31
  • No. It just for example. Try my code like i said above. – ucon89 Jan 10 '14 at 12:27

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.