Hi,
thanks for your question, and sorry for the trouble.
I see what you mean, and in deed, TablePress is currently not processing its Shortcode through an AJAX request. The reason for this is that it needs to load CSS and JS code, e.g. for the DataTables JS libraries.
Regards,
Tobias
Hi,
If I load DataTables JS libraries on my page load then can you please explain the process how can start processing TablePress Shortcode through Ajax request.
As it’s necessary for my site to have around 1500 post and having trouble with table press.
So, Please help us to figure out this issue.
Hi,
loading the library beforehand will not really be sufficient, as the JS initialization call will still need to be made.
So, if we can make this work, it will be without the JS features working.
Please see https://wordpress.org/support/topic/shortcode-not-working-when-fetching-post-content-via-ajax/ for some ideas.
Regards,
Tobias
Hi, TobiasBg Thanks for your reply,
We have used that method but when we used that method ajax providing internal server error.
Here is my code of the ajax function.
// My ajax call function
add_action(‘wp_ajax_getlatestpost’, ‘getlatestpost’);
add_action(‘wp_ajax_nopriv_getlatestpost’, ‘getlatestpost’);
function getlatestpost(){
global $post;
$latest_post = get_post(7);
$content = $latest_post->post_content;
TablePress::$controller = TablePress::load_controller( ‘frontend’ );
TablePress::$controller->init_shortcodes();
$content = apply_filters(‘the_content’, $content);
$content = str_replace(‘]]>’, ‘]]>’, $content);
echo $content;
wp_footer();
exit();
}
when I add controller ajax is providing internal server error.
I have put this code in my function.php file.
Thanks
Hitesh Mandli
Hi,
if you are getting internal server errors, you should check your error log files to see where the PHP error is.
Putting the two lines in your getlatestpost()
function might be too late. You should instead maybe run them directly after the init
hook.
Regards,
Tobias