It seems the problem lies within redefining a widget: a widget with the ID “recent-posts” already exists, and that’s causing some strange behaviour when saving the widget. This is possibly due the callback on saving the widget being on the original widget class WP_Widget_Recent_Posts
).
It’s not really a good idea anyway to redefine a widget; the widgets API is not intended to be used that way. Your problem can be fixed by using a unique widget ID; replace ‘recent-posts’ by another ID in
parent::__construct('recent-posts', __('Recent Posts'), $widget_ops);
And while you’re at it, rename the widget to avoid having duplicate widget titles:
parent::__construct( 'myplugin-recent-posts', __( 'My plugin: Recent Posts', 'myplugin_textdomain' ), $widget_ops );
Related Posts:
- Best practices regarding the creation of custom widgets?
- Using add_filter() in Widgets
- Dynamically Register Sidebars For Each Top Level Page
- add sidebar area to header of child theme
- Missing argument 2 for a custom function widgets_init
- How would go about if I just want a temporary function?
- How to insert custom widget in custom sidebar in theme activation?
- Right way to update widget on dynamic new input field
- How do you Permanently Delete Sidebars
- Custom Sidebar only on single post
- login_headertitle is deprecated since version 5.2.0
- Why is it so hard to add a class to the tag in the sidebar widget?
- Register_Sidebar overwriting itself and doesn’t exist in global $wp_registered_sidebars;
- How to echo Widget Title in Custom Frontend-Template Box
- Save_post – Warning: Cannot modify header information
- Modifying a WordPress Plugin
- How do you insert code into the sidebar?
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
- Adding A New Widget to WordPress Disables the Existing Widgets
- How to programmatically GET (to know) which Sidebar (or) which Menu is being used on Different Pages?
- Add the title of a widget as an ID – for anchor links
- my wordpress doesn’t save items to customized widget area
- Remove all video attachment, both files and post/postmeta from database?
- WordPress Ajaxifying not working properly
- WordPress function with attribute pass to template
- Will dequeueing in child theme functions.php file prevent Google Fonts from loading?
- Which method is more correct for removing WooCommerce Extensions menu item?
- Copying a widget class to functions.php results on a blank page
- True email confirmation for registration (keeping unvalidated users from user table)
- Change is_front_page() to is_page() to display ‘hero’ on entire site?
- How to add widget in main menu
- Replace image attributes for lazyload plugin on image elements with specific class
- WordPress hooks to call a function inside a construct
- How To Show Shortcodes In WordPress Custom Fields?
- Help! Need a different logo on my main page from my other pages
- True parameter but jquery register in header and not in the footer with wp_register_script
- Display page number on custom page title function
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- How to make an If Else on Excerpt Filter
- How to replace words in my posts and saved new words
- Fatal error: Call to undefined function add_action() – an untouched problem
- How do I integrate my Child Theme into a Custom Template?
- Sending Messages Back to the Template After Processing?
- Shortcode to eliminate and replace with
- Pass arguments to function class with do_action()
- Trying to Add a LEFT Sidebar?
- previous_post_link inside of a function?
- custom COOKIE on custom page
- widgets_init actions not fired from functions.php’s child theme
- Add functionality to post editor
- custom post with loading script per single post
- Best strategy for providing theme options using customizer
- What add_action reference should I be using or should I use do_action?
- Cannot access variables within a widget
- wp_nav_walker that interacts with widgets to setup mega menu
- Expanding a function to call a plugin or show a link
- Getting error while trying to use custom comment function
- Settings in functions.php used by a plugin
- WordPress Javascript Widget jQuery Dependency Issue
- Register a widget area when a theme option has been saved?
- unregister_sidebar in child theme not working
- 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
- functions.php / replacing div’s with new ones?
- Additional Sidebar
- Why does modifying my functions.php file always result in a server error
- Custom tabs widget don’t work in google chrome, is blocked, do not change the tabs. Why?
- function to return comma separated list of meta values
- Give a function a unique ID
- Post variables not displaying correctly in custom function
- Custom post type functions.php if statement on action
- Remove snippets of JS from core
- Do something when user creates post (that’s pending)
- How do I include the sidebar (with Widgets) in a custom theme?
- Removing Facebook contact field from user contact not working
- add variable to actions/functions across different files (woocommerce)
- How do I add functionality to images?
- Explode Array from Repeatable Custom Field
- WordPress Custom wp mail template return full template
- Problem with removing characters “<” – WpAllImport
- How to create a post without link in wordpress?
- How to crop image in WordPress with aspect ratio for any size of image
- multible shortcodes (for differnt values) with one function
- HELP: Code To Check Status And Write Debug Entry
- delete_term is not working properly with add_action()
- Swap WordPress “Widget Area” based on Page Template
- post_row_actions filter from parent theme not executing in child theme
- Customizer cuistom CSS Priority ordre Issue
- Copy and Modified WooCommerce function is_coupon_valid [closed]
- How to get variable from other function inside class function using add_action for Ajax call
- BuddyPress Edit activity function good practice
- Function attached to cron job not running but will run if called manually
- wp_login_form display no styled form
- Advanced Custom Fields in WP_Query: Clickable Text in List Format
- Submit CF7 form programmatically with WP-Cron?
- disable a specefic sidebar when user is log out
- wp_update_post breaks my function
- Add custom css to specific user