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 Mar 2 '15 at 5:54
  • Are you calling dynamic_sidebar( 'my-right-sidebar' ) somewhere, for example in sidebar.php? Mar 6 '15 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
    Mar 7 '15 at 19:29
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, privacy policy and cookie policy

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