I am looking for some assistance in opening WordPress posts in the Bootstrap Modal.
Right now I have a home page with a grid that pull posts.
I have it setup so that each post is in a square box and linked to open the Bootstrap Modal window.
The modal window should pull the data from the post which is clicked.
At this time, it only opens the latest post on the page no matter which post is clicked.
I assume I need to let the model window know which post has been clicked so it can pull the correct data but I am at a loss.
Any help would be appreciated.
Here is my current code:
<?php get_template_part('templates/page', 'header'); ?>
<?php if (!have_posts()) : ?>
<div class="alert">
<?php _e('Sorry, no results were found.', 'roots'); ?>
</div>
<?php get_search_form(); ?>
<?php endif; ?>
<div class="row">
<?php while (have_posts()) : the_post(); ?>
<?php
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );
?>
<a href="#myModal" data-toggle="modal">
<div class="span2" style="background: #09F url(<?php echo $src[0]; ?>) center no-repeat !important;">
<?php get_template_part('templates/content', get_post_format()); ?>
</div>
</a>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<h3 id="myModalLabel">
<?php the_title(); ?>
</h3>
</div>
<div class="modal-body">
<p><?php the_post_thumbnail(); ?></p>
</div>
<div class="modal-footer">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">Ã</button>
</div>
</div>
<?php endwhile; ?>
This has been answered and this is how it was done:
The grid and the modal window are in a loop.
I simply added
-<? the_ID(); ?>
to bot the<a href>
calling the modal window. and to the<div id>
for the modal window which somehow passes the post ID to the window allowing it to pull in the right information for the post.To get the wordpress post contents in bootstrap modal –
Call the modal file
Create the modal.php file in your theme folder