I want to load post in bootstrap Modal dynamically

                            div class="col-lg-4 col-md-4 col-sm-6 exhibitors-child"
                                div class="exhibitors-border"
                                    ?php the_post_thumbnail(); ?
                                    div class="find"
                                        a href="" data-toggle="modal" data-target="#exhibitors-child"smallFIND OUT MORE/small/a
                                    /div    
                                /div
                            /div

                            ?php endwhile; endif; wp_reset_query(); ?

                            !-- Modal --
                            div class="modal fade" id="exhibitors-child" tabindex="-1" role="dialog" aria-labelledby="exhibitors-childLabel" aria-hidden="true"
                                div class="modal-dialog" role="document"
                                    div class="modal-content"
                                        div class="modal-body"
                                            button type="button" class="close" data-dismiss="modal" aria-label="Close"
                                              span aria-hidden="true"times;/span
                                            /button
                                            ?php the_post_thumbnail(); ?
                                            h2?php echo get_field('name') ;?/h2
                                            p?php echo get_field('exhibitors_single_description') ;?/p
                                        /div
                                    /div
                                /div
                            /div

Topic twitter-bootstrap loop Wordpress

Category Web


Is this on a single page template, an archive page template, single post template? Where is this code supposed to be in relation to the main query? It's hard to provide advice or solutions without context on what you're trying to achieve.

If you're trying to create a section on a page template that pulls in your posts in addition to the content of the page, this would require that you make a secondary query to pull those posts in.

If what I described is what you're trying to do have a look at here: https://developer.wordpress.org/reference/classes/wp_query/

Basically, you'd make a new query outside of your main query (aka where the content of the page is coming from) a simple example is below. Many additional parameters are available to refine the query.

$newArgs = array(
    'post_type' => 'post',
);
$query = new WP_Query( $newArgs );

Then run a second loop and place your modal code within that, it looks like you're using ACF too which should be just fine. A basic example is below:

if ( $newArgs->have_posts() ) {
    while ( $newArgs->have_posts() ) {
        $newArgs->the_post(); 
        //
        // Modal code here
        //
    } // end while
} // end if

More on the loop here: https://codex.wordpress.org/The_Loop


Ensure you are using the correct template.

If you are on the single post type template you can use within your modal.

<?php the_content(); ?>

Learn more about post type templates here: https://codex.wordpress.org/Post_Type_Templates

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.