Support » Plugin: Gutenberg » Show or hide custom meta box not work with Gutenberg

  • Denis

    (@franchidesign)


    Hello,
    I’m on WordPress 5 beta 4,
    the problem is that meta boxes can not hide them when selecting a specific template chosen by page attributes.
    To make them appear or hide, you have to update the browser page or exit the created page and re-enter it.
    This is not very nice for users.
    This is my code:

    function willer_custom_meta_portfolio_standar() {
    	global $post;
    
    	if(!empty($post))
    	{
    		$pageTemplate = get_post_meta($post->ID, '_wp_page_template', true);
    		if($pageTemplate == 'template-pages/page-portfolio-standar.php' )
    		{
    			add_meta_box(
    				'page-portfolio-standar-meta-box', // $id
    				esc_html__('Customize Portfolio Standar','willer'), // $title
    				'willer_portfolio_standar_meta_callback', // $callback
    				'page', // $page
    				'normal', // $context
    				'high'); // $priority
    			}
    		}
    
    	}
    	add_action( 'add_meta_boxes', 'willer_custom_meta_portfolio_standar' );

    The problem also occurs with WordPress 4.9.8 using Gutenberg,
    using the classic editor the problem is not there.
    I think it’s because Gutenberg uses Ajax to save the options.
    Do you have any suggestions to solve the problem?
    Thank you

    • This topic was modified 2 years, 3 months ago by Denis.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Show or hide custom meta box not work with Gutenberg’ is closed to new replies.