• Resolved hiteshmandali

    (@hiteshmandali)


    Hello,

    I Have an issue with table press.

    Tablepress short-code displaying in post content instead of executing the short-code when I call content in ajax function.

    Short-code working properly when page load but not work’s when we call post content through ajax.

    So please help us to solve this issue.

    Thanks
    Hitesh Mandli

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    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

    Thread Starter hiteshmandali

    (@hiteshmandali)

    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.

    Plugin Author TobiasBg

    (@tobiasbg)

    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

    Thread Starter hiteshmandali

    (@hiteshmandali)

    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

    Plugin Author TobiasBg

    (@tobiasbg)

    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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Short Code Displaying when call post data through ajax’ is closed to new replies.