A
A
Alexander Sobolev2018-09-22 15:19:38
WordPress
Alexander Sobolev, 2018-09-22 15:19:38

How to enable metabox with Ajax?

I'm trying to load the necessary metabox(es) by event

add_action( 'wp_ajax_get_status_metabox','get_status_metabox' );
add_action( 'wp_ajax_nopriv_get_status_metabox','get_status_metabox' );
function get_status_metabox(){
   /* 1: */ wp_send_json( add_meta_box('estate_object_control', 'Статус объекта', 'estate_object_control', 'estate', 'normal', 'high') );
  /* 2: */ add_meta_box('estate_object_control', 'Статус объекта', 'estate_object_control', 'estate', 'normal', 'high')
}

JS is connected correctly. wp_send_json('test') outputs to the console)
success: function(response) {jQuery('#wpbody').append(response); console.log(response); }

There was even an option to send add_action, but the metabox is not displayed in any of the options..
The option with .hide() .show() will not work for me. a lot of data.. Even if the hide() bypasses the elements during the collection - this process, it seems to me, is a whole story..
How to display metaboxes with AJAX?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2018-09-22
@HeadOnFire

Use ACF Pro and conditional fields, you will be happy. Judging by the rest of the questions, your knowledge of PHP / JS is not enough to implement these tasks through code. Nothing personal.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question