1

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'   => '',
    ));
});
3
  • 2
    Welcome to WPSE :-). Without seeing your code, it is impossible to help you. Any answer or comment will only be speculation. File an edit and add all your relevant code to your question. Tip: If you add code in the editor, highlight all the code and click the {} sign in the top right hand corner above the editor once to add your code in a code block Commented Mar 2, 2015 at 5:54
  • Are you calling dynamic_sidebar( 'my-right-sidebar' ) somewhere, for example in sidebar.php? Commented Mar 6, 2015 at 10:49
  • @TheDeadMedic, that is not necessary to make the admin panel display properly. That is the primary concern given the description above.
    – AC4
    Commented Mar 7, 2015 at 19:29

1 Answer 1

1

I finally found out the short answer to the question 'Can you?' = Yes.

Simplicity is an art. This moved me to dig deeper.

It seems that the admin panel is not good at catching and displaying errors. What was happening was that the widget definition was throwing within broken markup. I could only see it if I viewed source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.