如何将wordpress过滤器应用于ajax加载的数据?

如何将wordpress过滤器应用于ajax加载的数据?,ajax,wordpress,Ajax,Wordpress,我已经为内容创建了一个ajax函数和过滤器,但是当我使用ajax响应获取数据时,我的过滤器不起作用。请帮帮我。这是我的密码: add_action("wp_ajax_nopriv_thb_infinite_ajax", "thb_infinite_ajax"); add_action("wp_ajax_thb_infinite_ajax", "thb_infinite_ajax"); function thb_infinite_ajax() { $args = array(

我已经为内容创建了一个ajax函数和过滤器,但是当我使用ajax响应获取数据时,我的过滤器不起作用。请帮帮我。这是我的密码:

add_action("wp_ajax_nopriv_thb_infinite_ajax", "thb_infinite_ajax");
add_action("wp_ajax_thb_infinite_ajax", "thb_infinite_ajax");
function thb_infinite_ajax() {
   $args = array(
        'p' => $previous_post->ID,
        'no_found_rows' => true,
        'posts_per_page' => 1
    );
    $query = new WP_Query($args);
    if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();

        the_content();
    endwhile; else : endif;

}

add_filter ( 'the_content', 'wpsabox_author_box', 5 );

wpsabox_author_box($content) {
    return $content.'----';
}
JS代码:

                       $.ajax( ajaxurl, {
                                method : 'POST',
                                data : {
                                    action : 'thb_infinite_ajax',
                                    post_id : tempid
                                },
                                beforeSend: function() {
                                    id = null;
                                },
                                success : function(data) {
                                    //container.removeClass('thb-loading');
                                    $( ".thb-loading" ).remove();


                                        $(data).appendTo( '#infinite-article' );    


                                }
                            });

提前感谢

试试这个……可能对你有帮助我更改了内容功能

function thb_infinite_ajax() {
   $args = array(
        'p' => $previous_post->ID,
        'no_found_rows' => true,
        'posts_per_page' => 1
    );
    $query = new WP_Query($args);
    if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();

        $result = get_the_content($post->ID);
    endwhile; else : endif;
echo $result;
}

请添加javascript代码Ajax代码并不重要,但我没有获得WordPress筛选器数据注意,筛选器函数必须在完成处理后返回内容我将如何添加筛选器以获得以下内容函数:添加筛选器('the_content','wpsabox_author_box',5);