Gallery shortcode via AJAX
-
Hello,
First of all, thanks for this great plugin. Good Work.
The problem that I have is that the owl carousel attached to the native WP gallery shortcode is not working properly for me when I load the template page via AJAX. When I load the respective single post page, everything works fine. But, when I try to call the page template via AJAX and populate my DIV, the HTML generated is different. It is missing div.owl-wrapper-outer, div.owl-wrapper and div.owl-item around the items. Do you know what the problem might be?
I am using a custom theme based on the Naked theme base. Maybe it is something that I am doing wrong. I am using this:
// Localize Scripts for $php_array = array( 'admin_ajax' => admin_url( 'admin-ajax.php' ) ); wp_localize_script( 'main', 'php_array', $php_array );
inside my wp_enqueue_scripts action hook. And this:
// Post AJAX functionality add_action( 'wp_ajax_post_ajax', 'post_ajax' ); add_action( 'wp_ajax_nopriv_post_ajax', 'post_ajax' ); function post_ajax() { $args = array( 'p' => $_POST['id'] ); $theme_post_query = new WP_Query( $args ); while( $theme_post_query->have_posts() ) : $theme_post_query->the_post(); get_template_part('format', 'standard'); endwhile; }
inside my functions.php.
I can also supply you with the AJAX call inside my main.js file.
Any hint, tip, help would be much appreciated.
- The topic ‘Gallery shortcode via AJAX’ is closed to new replies.