- This topic has 7 replies, 2 voices, and was last updated 1 year, 9 months ago by David.
June 28, 2019 at 7:39 am #943949jasmeet
I had been adding the code suggested here – https://digwp.com/2010/04/call-widget-with-shortcode/ to call widget with shortcode on guternberg block however after entering the code snippet in functions.php file of child theme, it’s returning with error as shown on screenshot – https://cl.ly/b6d100ec8f34
Can you assist with the same
RegardsJune 28, 2019 at 7:51 am #943959DavidStaffCustomer Support
have you added the same function more than once to your functions file? If so the functions both have the same name which is the problem.
If you’re looking at creating multiple shortcodes for widgets then this plugin will make that super easy:July 1, 2019 at 12:00 am #945711jasmeet
Thanks for the reply
1) Have reviewed once again however, I could see the functions code snippet once. Could it be that the similar code is existing somewhere else – maybe, in parent theme files etc as I am working through functions.php in child theme
2) Thanks for the suggestion. Had been using this plugin extensively, however this doesn’t work for some widgets.
Example – Instead of actual widget output, It is returning with this error although the widget has already been added as per steps outlined by the specific widget developer instructions. https://cl.ly/6d5d25897513
Will appreciate for any troubleshooting steps or workaround here 🙂July 1, 2019 at 5:05 am #945906DavidStaffCustomer Support
That error states that you’re redeclaring a widget function on line 109 – which has already been declared on line 16. So it has to be some code in your child theme functions that is causing the problem.
The plugin error also looks to be related to the code you’re adding – you can see that very error is within the shortcode function itself. You can see it on this line:
return '<p>'.sprintf(__("%s: Widget class not found. Make sure this widget exists and the class name is correct"),'<strong>'.$class.'</strong>').'</p>';
I would test by disabling your child theme function file or at least removing any shortcode/widet related code and then retry the pluginAugust 23, 2019 at 6:35 am #991526jasmeet
For troubleshooting purposes, I had disabled child theme and enabled parent theme and the shortcode for widget reflected fine..
Can you let me know the exact code snippet which can be added in functions.php file of child theme in order for specific shortcode being added to reflect fineAugust 23, 2019 at 8:02 am #991665DavidStaffCustomer SupportAugust 25, 2019 at 7:24 am #992870jasmeet
To replicate, You may install this plugin – https://wordpress.org/plugins/widget-shortcode/ to generate widget shortcode and thereafter, add the shortcode in hooks output area and similar error shall appear instead of actual output with child theme assigned!August 25, 2019 at 7:33 am #992876DavidStaffCustomer Support
If you’re using the widget shortcode plugin then you can remove all instances of the code you got from here:
It is that code that is displaying that error.
- You must be logged in to reply to this topic.