Wordpress 4.1.1: simular problem to another question: I have a add_action
widgets_init
call back in which I have a call to register_widget
that registers a class and a call to register_sidebar
that registers some sidebars. Only the Widget shows on the Widget admin page. If I comment out call to register_widget
the sidebars show. Can I define a widget and sidebars in a theme?
Here is the code from my functions.php:
add_action( 'widgets_init', function()
{
// -------------- WIDGETS ---------------------------------------------
require_once 'MyWidget.php';
register_widget( 'MyWidget' );
// -------------- WIDGETS ---------------------------------------------
register_sidebar(array(
'name' => __('Right Sidebar', 'text_domain'),
'description' => __('Appears on all pages that have a right sidebar.', 'text_domain'),
'id' => 'my-right-sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));
});
{}
sign in the top right hand corner above the editor once to add your code in a code blockdynamic_sidebar( 'my-right-sidebar' )
somewhere, for example insidebar.php
?