A clean WordPress theme has no default widgets, which are found in the admin under Appearance>Widgets
Code:
function custom_theme_setup_support() {
add_theme_support( 'widgets' );
}
add_action( 'after_setup_theme', 'custom_theme_setup_support' );
menu (by default there is no menu) and other elements are added in the same way
add_theme_support( ‘menus’ );
Here’s a breakdown of the code:
Function Definition:
custom_theme_setup_support(): This is a custom function name. You can change it to something more specific if you prefer.
Adding Theme Support:
add_theme_support( ‘widgets’ ): This line adds support for widgets to the theme. It enables the theme to use WordPress widgets in the sidebar or other widgetized areas.
Hooking into Theme Setup:
add_action( ‘after_setup_theme’, ‘custom_theme_setup_support’ ): This line hooks the custom_theme_setup_support function into the after_setup_theme action hook. The after_setup_theme action hook is fired after the theme is done setting up. This is a good time to add theme support for various features.
Leave a Reply