Support

Account

Home Forums General Issues Bootstrap Modal

Unread

Bootstrap Modal

  • Good day Devs,

    I am creating a site using ACF Pro and I’m trying to use a Bootstrap modal to pull in info on a CPT (presenter). Any ideas on how to get this working would be greatly appreciated.

    <?php
    
                                /*
                                *  Loop through post objects (assuming this is a multi-select field) ( setup postdata )
                                *  Using this method, you can use all the normal WP functions as the $post object is temporarily initialized within the loop
                                *  Read more: http://codex.wordpress.org/Template_Tags/get_posts#Reset_after_Postlists_with_offset
                                */
    
                                $post_objects = get_field('presenter');
                                $post_id    = get_the_id();//make sure this getting the correct post id
    
                                if( $post_objects ): ?>
                                    <div class="team-carousel">
                                        <?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
                                            <?php setup_postdata($post); ?>
                                            <div class="carousel-cell member text-center">
                                                <?php
                                                if ( has_post_thumbnail() ) {
                                                    the_post_thumbnail( 'presentation-thumbnail', array( 'class'  => 'img-fluid mb-3' ) );
                                                }
                                                ?>
                                                
                                                        <?php the_title(); ?>
                                                
    
                                                <span><?php the_field('position'); ?></span>
                                                
                                                    <a class="btn btn-primary btn-block mt-3" data-toggle="modal" data-target="#presenter">
                                                        View More
                                                    </a>
                                                
    
                                            </div>
    
                                        <?php endforeach; ?>
                                    </div>
    
                                    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    
                                <?php endif; ?>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.