Home>Support>Post meta boxes loose content when Post is saved as a draft

Post meta boxes loose content when Post is saved as a draft

Hi there,

When adding content into Widgets Bundle Post Meta Data fields and saving Post as a draft all content disappears.
Few clients complained about it, so if you can at least confirm that that’s is a known issue, it will be great and take off pressue from us for trying to find a solution for it.

Cheers,
Olga

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 6 years, 6 months ago Alex S
    Hi, I Work Here

    Hi Olga,

    Unfortunately, this isn’t a known issue. Can you try disabling all non-SiteOrigin plugins and see if this fixes the issue? You’ll need to clear all your caches after disabling your plugins.

    If it does fix the issue, then try re-enabling your plugins one by one until the issue comes back. This procedure will help diagnose which plugin is causing the issue.

    Once we know that, we’ll be able to look at what might be causing the conflict and either solve the problem or help you find an alternative plugin.

    If you aren’t using a SiteOrigin theme, then you can also try temporarily switching to one of the default WordPress themes to see if the issue is theme related.

  2. 6 years, 5 months ago [email protected]

    Hi Alex,

    The issue occurs on the clean WP installation only with Site Origin Page Builder and Widgets Bundle installed.
    Also tried on few different installations of WP which are on a different servers.
    Here are steps to replicate the issue:

    1. Go into ‘Custom post type’ -> Add new (custom post type that has Widgets Bundle Post Meta Data fields associated)
    2. Add data into any fields and click on ‘Save as draft’ at the top in Publish right hand side menu.
    3. All data will disappear from Widget Bundle Post Meta Data fields
    4. .

    Thanks,
    Olga

  3. 6 years, 5 months ago Alex S
    Hi, I Work Here

    Hi Olga,

    To clarify, what is adding your custom post types?

    Also, regarding this:

    Widgets Bundle Post Meta Data fields

    Can you please elaborate on what that is? I ask because we’re not familiar with this. It’s quite possible what it is known under a different name to us which is why we’re not too sure what you’re referring too so you may need to elaborate on the exact steps you’re doing to do this. Hm. Are you talking about enabling SiteOrigin page Builder for that post type (WP AdminSettingsPage Builder, open General tab and tick Post Type).

  4. 6 years, 5 months ago [email protected]

    Hi Alex,

    I add Custom post type using the following function in functions.php:

    register_taxonomy_for_object_type('category', 'event'); // Register Taxonomies for Category
    //register_taxonomy_for_object_type('post_tag', 'event');
    register_post_type('event', // Register Custom Post Type
        array(
            'labels' => array(
                'name' => __('Event', 'event_theme'), // Rename these to suit
                'singular_name' => __('Event', 'event_theme'),
                'add_new' => __('Add New', 'event_theme'),
                'add_new_item' => __('Add New Event', 'event_theme'),
                'edit' => __('Edit', 'event_theme'),
                'edit_item' => __('Edit Event', 'event_theme'),
                'new_item' => __('New Event', 'event_theme'),
                'view' => __('View Event', 'event_theme'),
                'view_item' => __('View Event', 'event_theme'),
                'search_items' => __('Search Event', 'event_theme'),
                'not_found' => __('No Events found', 'event_theme'),
                'not_found_in_trash' => __('No Events found in Trash', 'event_theme')
            ),
            'public' => true,
            'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
            'has_archive' => true,
            'rewrite' => array(
                'with_front' => false
            ),
            'supports' => array(
                'title',
                'editor',
                'excerpt',
                'thumbnail'
            ), // Go to Dashboard Custom HTML5 Blank post for supports
            'can_export' => true, // Allows export in Tools > Export
            'taxonomies' => array(
                'post_tag',
                'category',
                'office'
            ) // Add Category and Post Tags support
        ));

    Then I add a custom widget in \wp-content\plugins\so-widgets-bundle\widgets\.
    In the php file where variables defined I would add the following using this functionality: https://siteorigin.com/docs/widgets-bundle/advanced-concepts/post-meta-box-forms/

    <?php
    /*
    Widget Name: Konstructive Event Details
    Description: Event details
    
    */
    
    class Konstructive_Event_Details extends SiteOrigin_Widget {
    	function __construct() {
    
    		parent::__construct(
    			'konstructive-event-details',
    			__('Konstructive Event Details', 'Konstructive Widgets Suite'),
    			array(
    				'description' => __('Event details', 'Konstructive Widgets Suite')
    			),
    			array(
    
    			),
    			false,
    			plugin_dir_path(__FILE__)
    		);
    
    	}
    
    	function initialize() {
    		global $sow_meta_box_manager;
    		$sow_meta_box_manager->append_to_form(
    			$this->id_base,
    			array(
    
    			'event_link_url' => array(
    				'type' => 'link',
    				'label' => __('Event Link URL', 'konstructive-widgets-suite'),
    				'description' => __('Event CTA, can be used for Register link. Please choose link destination or enter absolute URL', 'konstructive-widgets-suite')
    			),
    
    			'event_link_text' => array(
    				'type' => 'text',
    				'label' => __('Event Link Text', 'konstructive-widgets-suite'),
    				'description' => __('Event CTA, can be used for Register link. Please specify link text', 'konstructive-widgets-suite')
    			),
    
    			// Event start date and time
    		    'event_date' => array(
    				'type' => 'text',
    				'rows' => 4,
    				'label' => __('Event Date', 'konstructive-widgets-suite')
    			),
    
    			// Event date and time
    		    'event_time' => array(
    				'type' => 'text',
    				'rows' => 4,
    				'label' => __('Event Time', 'konstructive-widgets-suite')
    			),
    
    		    // Event location
    		    'event_location' => array(
    				'type' => 'tinymce',
    				'rows' => 4,
    				'label' => __('Event Location', 'konstructive-widgets-suite')
    			),
    
    		    // Google Map location URL
    			'event_google_map_url' => array(
    				'type' => 'link',
    				'label' => __('Google Map URL', 'konstructive-widgets-suite'),
    				'description' => __('Please enter full URL to Google Map location')
    			),
    
    		),
    			array( 'event' )
    		);
    	}
    
    	function get_template_variables( $instance, $args ) {
    		// Return data to the template
    		return array(
    			'id_base' => $this->id_base,
    			'event_link_url' => $instance['event_link_url'],
    			'event_link_text' => $instance['event_link_text'],
    			'event_date' => $instance['event_date'],
    			'event_time' => $instance['event_time'],
    			'event_location' => $instance['event_location'],
    			'event_google_map_url' => $instance['event_google_map_url']
    		);
    	}
    
    }
    
    siteorigin_widget_register('konstructive-event-details', __FILE__, 'Konstructive_Event_Details');

    Here is how it looks in the wp-admin: http://cs-pub.konstructive.com/test/Meta-boxes-SO.jpg
    So Meta boxes content added using code above would loose all content when saving Event post as a draft.

    Please let me know if you need any more details.

    Thanks,
    Olga

  5. 6 years, 5 months ago Alex S
    Hi, I Work Here

    Hi Olga,

    Thanks. I’ve been able to replicate this issue with the provided code. I’ve logged this as a bug and the development team will look into this shortly.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More