Why excerpt hook not working inside ajax function?
Question
I am using ajax to display more posts.
My ajax function looks like this.
public function view_more_posts(){
$more_post = new WP_Query(array(
'post_status' => 'publish',
'paged' => $_POST[ 'page' ],
'posts_per_page' => get_option( 'posts_per_page' )
));
if( $more_post->have_posts() ){
while( $more_post->have_posts() ){
$more_post->the_post();
the_title();
the_excerpt();
}
}
wp_reset_postdata();
die;
}
add_action( 'wp_ajax_view_more_posts','view_more_posts' );
add_action( 'wp_ajax_nopriv_view_more_posts','view_more_posts');
My problem is that I have customized excerpt_length and excerpt_more but I am not getting customized excerpt. Instead I am getting default excerpt by wordPress.
Why these hook are not working inside ajax?? How I can I get correct excerpt?
0
4 months
0 Answers
10 views
0
Leave an answer
You must login or register to add a new answer .