How to apply a filter to rezultatu AJAX request in Wordpress?

Good morning everyone!
Maybe find someone who can help...
There is a filter
add_filter('post_gallery', 'custom_gallery', 10, 2);

and there is a function that generates a gallery on the ajax request.

add_action('wp_ajax_get_gal', 'ajax_gallery_reload');
add_action( 'wp_ajax_nopriv_get_cat', 'ajax_gallery_reload' );
ajax_gallery_reload function(){
 $gal = !empty($_POST['gal']) ? esc_attr($_POST['gal']) : false;
 $pid = !empty($_POST['pid']) ? esc_attr($_POST['pid']) : false;
 $gallery = get_post_galleries($pid, false);
 but this do_shortcode echo('[gallery ids=' . $gallery[$gal - 1]['ids'] . ']');

The filter works in the records in which there is no Ajax...
How to apply it to the result of an ajax request?
June 14th 19 at 20:16
1 answer
June 14th 19 at 20:18
Filter "post_gallery" is in the function gallery_shortcode()
In ajax requests, you use get_post_galleries(), in this function there is no filter post_gallery.

Find more questions by tags AJAXjQueryPHPWordPress