That base class also contains information about the functions that must be extended to get a working widget.
Many of the default WordPress widgets leave something to be desired. Fortunately, it’s super-easy to override any of the default widgets with your own creations. For example, here is one way to replace the default Search Widget with your own version:
Now we need to create custom function to display search form using WordPress Widget function and WordPress Hook.
Put below code in active theme’s function.php file
<?php
function custom_search_widget() { ?>
<form action="http://localhost/283/index.php" method="get">
<div>
<label for="s">Site Search</label>
<input id="s" name="s" alt="Search" type="text" />
</div>
</form>
<?php } if (function_exists('register_sidebar_widget'))
register_sidebar_widget(__('Search'), 'custom_search_widget');
?>
/*--add in function.php--*/
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'Sidebar Widgets',
'id' => 'sidebar-widgets',
'description' => 'Widget Area',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
}
/* ----call this------*/
if ( is_active_sidebar( 'sidebar-widgets' ) ) :
dynamic_sidebar( 'sidebar-widgets' );
endif;
I hope you have done it successfully.
In this tutorial, I have write code to add custom meta query in main query…
This website uses cookies.