0

What I am trying to achieve is to create a grid with bootstrap inside a wordpress page and display 30 posts as thumbnails. By clicking on the thumbnail a modal box will be displayed with the image in full size.

What am I doing right now is that the modal pops up but displays the same image every time. I am trying to set the href value in the tag that will display the of the post in the modal.

    <?php get_header(); ?>


    <div id="content" class="clearfix">
        <div id="main" class="clearfix" role="main">
            <?php $counter = 0; ?>
             <div class="row-fluid">
            <?php if (have_posts()) : while (have_posts()) : the_post();?>
                <?php if ($counter < 4): ?>
                    <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix thumbnail-post span3'); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
                        <header>
                            <a href="#myModal" data-toggle="modal" >
                                    <?php the_post_thumbnail( 'graphix-thumbnail' ); ?>
                                    <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
                            </a>
                            <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">                                
                                <div class='modal-body'>
                                    <img src="<?php echo $url; ?>" />
                                </div>
                            </div>
                            <div class="page-header"><h3 itemprop="headline"><?php the_title(); ?></h3></div>
                        </header> <!-- end article header -->

                        <section class="post_content clearfix">
                            <?php the_content(); ?>
                        </section>
                    </article> <!-- end article -->
                <?php $counter +=1; ?>
                <?php else: ?>
                    </div>
                    <?php $counter = 0; ?>
                    <div class="row-fluid">
                <?php endif; ?>



            <?php endwhile; ?>          
            <?php else : ?>
            </div>
            <?php endif; ?>

        </div> <!-- end #main -->    
    </div> <!-- end #content -->

<?php get_footer(); ?>
Radolino
  • 1,834
  • 4
  • 26
  • 48

2 Answers2

0

See this question. Its pretty easy to pass data to a modal with jQuery.

Community
  • 1
  • 1
Schmalzy
  • 17,044
  • 7
  • 46
  • 47
0

What I did wrong was that the modal's identifier was the same and the id has to be unique. So I changed the id of the modal to "#myModal-" and each one got its own unique id !

Radolino
  • 1,834
  • 4
  • 26
  • 48