[Resolved] Custom menu widget programatically via xml-rpc
Hi, I’m trying to register custom menu widget using xml-rpc calls (it’s possible with Extended api plugin). I’m using wp_register_sidebar_widget function but it seems to do nothing. I call it with those parameters:
wp_register_sidebar_widget( 'custom_menu_widget-1', 'My name', 'WP_Nav_Menu_Widget', array( 'description' => 'blogroll' ) );
I suspect 3rd parameter (‘WP_Nav_Menu_Widget’) may be wrong, but I can’t find anywhere what should be output callback for standard custom menu widget. I can’t and I don’t want to edit function.php on the site. I wan’t to register standard custom menu widget to enable it in a sidebar. Maybe there is another way to achieve this? Could anyone help me with that?
The callback needs to be a function you’ve defined that displays the widget by outputting html. I’m not familiar with using this function, it appears to be an outdated method. I suggest you read Widgets API and the linked resources at the end. Then attack the problem again from this new angle. Good luck!
HI bcworkz, thanks for your reply. I didn`t found any signs that this is outdated method. The codex said only that this is new version of register_sidebar_widget. But You have right with this new angle. I resolved this problem in this way:
$nav_name = 'Menu name'; $nav_menu_id = wp_create_nav_menu($nav_name); $registered_widgets = get_option('wiget_nav_menu'); $registered_widgets = array('title'=>'widget title', 'nav_menu'=>$nav_menu_id); update_option('widget_nav_menu',$registered_widgets);
This creates widget which we can enable in sidebar. Cheers.
Yes, nothing anywhere says it is outdated. However, it does create a single use widget, which is an outdated mode. There are functions in core that upgrade single use to multi use, causing me to view single use as outdated. That is why I said it appeared outdated. I’m not saying it is deprecated or obsolete. Maybe outdated wasn’t the best choice of words. Old Fashioned?
I hope that explains things better. I’m pleased things are resolved to your satisfaction.
- The topic ‘[Resolved] Custom menu widget programatically via xml-rpc’ is closed to new replies.