You missed a lot of things . You have to add add action hook in your code. In below I give you an ideal widget code. Now try this.Replace your code with mine. Hope it will work. Thanks
function test_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'test' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'test' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'test_widgets_init' );
Related Posts:
- Right way to update widget on dynamic new input field
- Best practices regarding the creation of custom widgets?
- How to echo Widget Title in Custom Frontend-Template Box
- New checkbox in custom widget isn’t saving data
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
- When should you, and when should you not, use wp_list_pluck()?
- Can the new 4.8v text widget visual editor be removed?
- Display random categories on the front page (Finding and Editing Theme Functions)
- How to influence the information displayed on widget inside wp-admin
- Woocommerce add to simple product attribute programmatically [closed]
- How can I get $id variable in widget’s form function?
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- Using add_filter() in Widgets
- remove the wrapping of text widget or
- Programmatically Add Font-Awesome Icons to Category Widget
- Set default options for inserting media
- Authors details such as social media links, emails etc → Is this Meta or something else?
- Default or Preset Content for Custom Post Types
- Dynamically Register Sidebars For Each Top Level Page
- Remove tag on my RSS Feed
- Displaying Widgets
- Theme-Config tab in admin Pannel?
- How to Add a Random Custom Gravatar in the WordPress Comments?
- Delete pages and Create default pages for all new network sites
- Ajaxing function in widget class
- Actions according to image type and size
- Increment price for Woocommerce Minicart [closed]
- Post thumbnail relative link and HTML modify
- Missing argument 2 for a custom function widgets_init
- How to mass-delete inline styles in WordPress custom post type automatically?
- How would go about if I just want a temporary function?
- Remove the deleted users avatar from list
- How to call custom function from functions.php in site-wide template files?
- PHP files included in functions.php don’t seem to work
- How Can I Expand the WordPress Customize window without any Plugin?
- Set quantity of woocommerce product on page visit [closed]
- str_replace function in theme
- How to insert custom widget in custom sidebar in theme activation?
- Passing values from a widget to a function within a plugin
- Override widget in function WordPress
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- Word Press – Dynamic Content [closed]
- How can I make a widget shortcode to control all the widgets?
- Insert image in WordPress with HTML5 tag and caption function
- how can I just add to parent theme function(s) instead of redeclaring whole the function
- Replace a menu with widget or a custom template file programmatically
- Custom taxonomy widget in admin area
- Skeleton Child Theme Add Icon Bar to Header Flex Grid
- Dashboard widget custom positioning?
- How do you Permanently Delete Sidebars
- Custom Sidebar only on single post
- Custom HTML markup
- Use a shortcode to display custom meta box contents
- Create custom function for hero image
- Add attribute only to first image of every post via functions.php
- The_content and Preg_replace in loaded Iframe [closed]
- Create a Woocommerce product widget with category filter
- Add element to widgetpage
- “All posts” in the category widget
- two search forms on the same page
- Insert a field with PREG_REPLACE – strange behaviour
- Linking Javascript in functions.php file
- how to display a page before the home page
- How to conditionally add a widget via a hook in functions.php
- How Do I include/Import a Custom Widget from the Parent theme into My Child Theme?
- Function to check if custom page is used by page?
- Add a custom function to widget code
- How to remove font awesome from loading in wp theme
- Enable accessibility mode in widget as default
- Header menu aligned right on all pages except for single-post page [closed]
- Hide author info in single posts by certain users
- Widget is displayed in two places
- Trying to change widgets h-tags
- Shortcode to insert default text and change one word throughout it?
- I want to customize the_posts_navigation function by replacing prev and next with images
- How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?
- How would I correctly implement a new if statement in a child functions file?
- WordPress Ajaxifying not working properly
- WordPress function with attribute pass to template
- True email confirmation for registration (keeping unvalidated users from user table)
- How to add widget in main menu
- How To Show Shortcodes In WordPress Custom Fields?
- How to make an If Else on Excerpt Filter
- How do I integrate my Child Theme into a Custom Template?
- Shortcode to eliminate and replace with
- custom post with loading script per single post
- wp_nav_walker that interacts with widgets to setup mega menu
- WordPress Javascript Widget jQuery Dependency Issue
- Get Value of Custom Field
- restrict access to specific urls on a specific period of time
- child_of not working while searching
- How to request login for user but not for bots
- Removing Facebook contact field from user contact not working
- How do I add functionality to images?
- Problem with removing characters “<” – WpAllImport
- How to crop image in WordPress with aspect ratio for any size of image
- multible shortcodes (for differnt values) with one function
- Swap WordPress “Widget Area” based on Page Template
- Customizer cuistom CSS Priority ordre Issue
- Copy and Modified WooCommerce function is_coupon_valid [closed]