0

In a wordpress page I have a list of posts, each one links to a Bootstrap Modal where I want to load the post content.

This is my PHP function (inside a custom plugin). Gets the post ID and return content.

add_action('wp_ajax_nopriv_get_obra', 'getObraAJAX');
add_action('wp_ajax_get_obra', 'getObraAJAX');

function getObraAJAX(){
    $post = get_post($_GET['id']);
    WPBMap::addAllMappedShortcodes();
    $content = $post->post_content;
    $content = apply_filters('the_content', $content);
    echo $content;
    die();
}

This is my JS conde. Gets AJAX response and put it inside the modal.

function getObra(id) {

        $.ajax({
            url: "'.get_site_url().'/wp-admin/admin-ajax.php?action=get_obra&id="+id,
            cache: false
        })
        .done(function( response ) {
            $(".modal-body").html(response);
            $("#obraModal").modal("show");
        });

}

The posts are made with WPBakery and includes a carouser [vc_images_carousel] but the modal shows all the images, not a carousel.

I assume I need to run some JS to "build" the carousel but I don't know how.

You can see the page here http://puchetaconstrucciones.com.ar/obras-2/

0

I found the solution: The page was missing vc_carousel.min.css transition.min.js and vc_carousel.min.js With these files loaded, the corousel works fine

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.