• Resolved najmul002

    (@najmul002)


    I have multi paged post. many of them have google chart. I have used visuablizer plugin to integrate with google chart. It was working perfectly.

    But, when I try to add ajax pagination it shows nothing! Just the shortcode itself.

    I have applied “the_content” filter like:

    function ajax_load_page(){
    	$post_id = $_REQUEST['id'];
    	$page = $_REQUEST['page'];
    
    	$post = get_post($post_id);
    
    	$content = $post->post_content;
    	if ( false !== strpos( $content, '<!--nextpage-->' ) ) {
    		if ( $page > 1 )
    			$more = 1;
    		$content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content );
    		$content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content );
    		$content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content );
    		// Ignore nextpage at the beginning of the content.
    		if ( 0 === strpos( $content, '<!--nextpage-->' ) )
    			$content = substr( $content, 15 );
    		$pages = explode('<!--nextpage-->', $content);
    		$numpages = count($pages);
    		if ( $numpages > 1 )
    			$multipage = 1;
    	} else {
    		$pages = array( $post->post_content );
    	}
    	$shortcode_content = $pages[$page - 1];
    	$shortcode_content = apply_filters( 'the_content', $shortcode_content);
    
    	$previous = false;
    	$next = false;
    
    	if(count($pages) > $page)
    		$next = $page + 1;
    	if($page > 1)
    		$previous = $page -1;
    
    	wp_send_json(array('previous'=>$previous, 'next'=>$next, 'content'=>$shortcode_content));
    }
    
    add_action( 'wp_ajax_load_page', 'ajax_load_page' );
    add_action( 'wp_ajax_nopriv_load_page', 'ajax_load_page' );

    can you please what I am doing wrong?

    https://wordpress.org/plugins/visualizer/

The topic ‘shortcode not working correctly’ is closed to new replies.