When you register a sidebar in WordPress, is it possible to choose in what order it appears in the admin

Sidebars are output in registration order, which is implicitly captured by how they are added to a $wp_registered_sidebars global. This can easily be manipulated, for example following code will move first sidebar to the start: add_action( ‘register_sidebar’, function ( $sidebar ) { global $wp_registered_sidebars; if ( ‘first’ === $sidebar[‘id’] ) { $sidebar = $wp_registered_sidebars[‘first’]; unset( … Read more

How can I add a specific, custom widget to my theme’s header.php?

The WordPress codex mentions you should call the Widget Class name. Could it be that openingTimesWidget is a function instead of a Class? Following the WP Class naming convention your class would be written like this Opening_Times_Widget. https://codex.wordpress.org/Widgets_API Another possible reason that the widget is not displaying could have to do with the way your … Read more

dynamic sidebar not showing anything

In your functions.php file try register sidebar without putting in function like this register_sidebar(array( //try not to enclose this in function ‘id’ => ‘primary’, ‘name’ => ‘Primary Sidebar’, ‘description’ => ‘A short description of the sidebar.’, ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<h3 class=”widget-title”>’, ‘after_title’ => ‘</h3>’, )); And make … Read more

Adding a widget to a string of HTML

If you want to add the widget area as part of the output var you need to use the ob functions because it is echoed and not returned. Like this: $output .= ‘<div id=”header-image-widget-area”>’; ob_start(); dynamic_sidebar( ‘header_image_widget’ ); $output .= ob_get_clean(); $output .='</div>’;

WordPress menu deletes when trying to add a hook

I don’t think there’s wp_nav_menu action. Perhaps you want the wp_nav_menu filter (doc)? function custom_novice_menu($args) { if( ‘primary’ == $args[‘theme_location’] ) // only apply to the right menu { $args[‘container’] = ‘div’; } return $args; } add_filter(‘wp_nav_menu’, ‘custom_novice_menu’);

Show Specific Footer Widget for Specific Pages

There are several ways you can achieve this: A. Use CSS to hide and show widgets based on which page you are on. This is fine as a workaround, but it isn’t really solving your problem, especially if you have lots of pages/widgets. B. Call a different widget area in your template file with conditional … Read more