searchform.php override not working

I'm taking a Udemy class to learn how to make Wordpress plugins and themes. The video I'm on is having me override the default search widget with a custom one via searchform.php. From what I've gathered, this file should automatically be loaded with the rest of the theme as long as I have followed these steps:

/theme_dir/functions.php

/* Some other code */
include ( get_theme_file_path('/includes/widgets.php') );
add_action(widgets_init, 'ju_widgets');

/theme_dir/includes/widgets.php

function ju_widgets() {
    register_sidebar([
        'name'          = __('My First Theme Sidebar', 'udemy'),
        'id'            = 'ju_sidebar',
        'description'   = __('Sidebar for the theme Udemy', 'udemy'),
        'before_widget' = 'div id=%1$s class=widget clearfix %2$s',
        'after_widget'  = '/div',
        'before_title'  = 'h4',
        'after_title'   = '/h4',
    ]);
}

/theme_dir/sidebar.php

div class=sidebar nobottommargin col_last
    div class=sidebar-widgets-wrap
        ?php
            if (is_active_sidebar('ju_sidebar')) {
                dynamic_sidebar('ju_sidebar');
            }
        ?
    /div
/div

/theme_dir/searchform.php

?php $unique_id = esc_attr( uniqid( 'search-form-' ) ); ?

form role=search method=get class=search-form
      action=?php echo esc_url( home_url( '/' ) ); ?
    div class=input-group
        input type=search id=?php echo $unique_id; ?
               class=form-control name=s
               value=?php the_search_query(); ?
               placeholder=?php _e( 'Search', 'udemy' ); ?/
        span class=input-group-btn
            button type=submit class=btn btn-dangeri class=icon-search/i/button
        /span
    /div
/form

/theme_dir/index.php

!-- some theme html --

?php get_sidebar(); ?

!-- other theme html --

No matter what I change in the searchform.php file, it doesn't replace the default search widget.

Topic sidebar widgets forms theme-development Wordpress

Category Web


The person who posted this question is probably taking this Udemy course because I recognize the code: Complete WordPress Developer Course - Plugins & Themes

I'm also taking the course and here's how I made the searchform.php template file work in my Gutenberg WordPress site:

  1. Install the Disable Gutenberg plugin and inside the settings (like localhost/wp-admin/options-general.php?page=disable-gutenberg) next to the Classic Widgets heading check the Disable Block Widgets and enable Classic Widgets checkbox and click Save Changes.

  2. Go back to the Widgets Admin page (like localhost/wp-admin/widgets.php) and remove the existing widgets (which will probably be Gutenberg blocks) and add the available classic WordPress widgets.

Finally, the Udemy course above does include sections on Gutenberg (Gutenberg Prerequisites, Gutenberg Development, etc.) so I believe the course is still worth taking. And you get into the Gutenberg sections of the course you can disable or uninstall the Disable Gutenberg plugin and Gutenberg features will be restored.


This way of working with widgets is outdated and I should be using Gutenberg blocks. Moral of the story, be careful when buying courses from Udemy, they may just be useless.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.