shortcodes, filters and ajax
Could you figure out why I’m unable to get shortcode filters applied in ajax inclusion of posts?
Let me explain better: I’ve managed to include a post from within another post, through admin-ajax.php.
Obviously I don’t want to display the shortcode tags, nor I’d like to strip them, so I’m echoing
At this point, the post gallery gets rendered but unfiltered, even though I’m running the “Cleaner Gallery” plugin, which starts with
add_filter( 'post_gallery', 'cleaner_gallery', 10, 2 );and succesfully works in normal (non-ajax) posts.
I’ve been trying to debug this issue by replacing
$output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) return $output;
$output = apply_filters('post_gallery', '', $attr); echo 'FILTERED OUTPUT = '.$output.' !'; if ( $output != '' ) return $output;
inside the function gallery_shortcode($attr) located in wp-includes/media.php.
It seems that it runs twice, but in ajax inclusions the output is empty at first time and then it’s not filtered.
Please help me!
- The topic ‘shortcodes, filters and ajax’ is closed to new replies.