I made a custom widget and everything is showing fine in the back end. The widget is populated and the info saves. My problem is that nothing is showing on the front end. Not even simple html. I have shortened my code for easier reading. Just took out some of the settings. In the tpl folder, I have a file named address.php that should display the front end but I get nothing. Are there any common errors that would prevent it from showing on the front end? Not even the html shows. The widget displays on the back end and works just fine.
File structure
address-widget
folder assets
folder styles
folder tpl
address.php
address-widget.php
/* Widget Name: Mosty Address Widget Description: Displays a formatted address widget!'. */ class Address_Widget extends SiteOrigin_Widget { function __construct() { parent::__construct( 'address', __( 'Mosty Address Widget', 'mosty' ), array( 'description' => __( 'A formatted address widget', 'mosty' ), ), array( ), false, plugin_dir_path(__FILE__) ); } function get_widget_form() { return array( 'title' => array( 'type' => 'text', 'label' => __('Title.', 'mosty'), 'default' => 'Contact Us' ), ); } function get_template_name($instance) { return 'address'; } function get_style_name($instance) { return 'address-style'; } } siteorigin_widget_register('mosty_address_widget', __FILE__, 'Address_Widget');
Hi ThemeBuddies,
Can you please send me a complete archive of the referenced widget? This will allow me to get a better idea of why this may not be working. Sorry mate.
Alex, I figured it out. I believe part of the issue is that there is not enough information in the tutorial for creating a widget to make it work without problems. I think it came down to having incorrect information in the constructor. I have it working but I had to poor over other plugins for the siteorigin page builder to figure it out.
Hi ThemeBuddies,
Can you please provide specifics on what you feel is missing in the documentation? I’m not saying our documentation is perfect, I just need more information on what you feel is lacking specifically so I can forward that to Andrew so this can be corrected. Oddly, I just tried and was able to follow the documentation without issue so I’m not too sure what steps are missing.
I am sure it’s ok. There is just more information that could be in there. Like why the constructor is holding the form fields when they could go in a function called get_widget_form