How to add a widget in a custom theme in WordPress?
So the problem is like this. I am starting to learn WordPress. Now, I came across a very cool plugin (http://wordpress.org/extend/plugins/wp-tagcanvas/). Now when I use the built-in theme, and activate the plugin, I can see it on my sidebar. All good till here. Now, I try to have a custom theme of my own. I understand that all the widgets on the twenty-eleven sidebar come up due to some function calls in one of the many template files. So I decipher that I need to make similar call in my sidebar.php.
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?> <div id="first" class="widget-area" role="complementary">
So now the “Search” widget comes up in my sidebar . And along with it I see a heading “Tag cloud” and then nothing. While, if I use Twenty-eleven theme, I get a fully-functional 3d cloud widget.
I have gone through the readme.txt file of the plugin. I have follwed the instructions there correctly, as I am able to see the cloud widget in the twenty-eleven theme.
Can anyone help me on what I am doing incorrect here or if I am missing something.
Another question that I have is how can I display a widget using its index. I wrote these lines:
<?php $the_sidebars = wp_get_sidebars_widgets(); print_r( $the_sidebars); ?>
which give the following output:
Array ( [wp_inactive_widgets] => Array (  => calendar-2  => search-3 ) [sidebar-1] => Array (  => search-2  => tag-cloud-html5 ) [sidebar-2] => Array ( ) [sidebar-3] => Array ( ) [sidebar-4] => Array (  => rss-2 ) [sidebar-5] => Array ( ) )
So, if I need to display, say rss widget at some place, how do I do it using it’s index? Thanks in advance for your help
- The topic ‘How to add a widget in a custom theme in WordPress?’ is closed to new replies.