Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created a blog template, to show a custom posts in a grid of 3 columns.

like this

            <ul class="grid effect-6" id="grid">
                    <?php
                        //WordPress loop for custom post type
                         $my_query = new WP_Query('post_type=online_courses');
                          while ($my_query->have_posts()) : $my_query->the_post(); ?>

                    <li class="viewoc viewoc-tenth">

                        <img src="<?php echo $cfs->get('top_image_oc'); ?>" style="background-color: <?php echo $cfs->get('add_bg_color'); ?>; "/>

                        <h1><?php the_title(); ?></h1>

                        <button class="md-trigger" data-modal="modal-8">Find Out More..</button>
                    </li>

                <div class="md-modal md-effect-8" id="modal-8">
                    <div class="md-content">
                        <div>
                            <h1 style="color: #0D3D62;margin-top:0;margin-bottom:0;line-height:50px;font-size: 50px;"><?php echo $cfs->get('trainer_name'); ?></h1>
                            <h1 style="color: #0D3D62;margin-top:0;margin-bottom:0;line-height: 50px;font-size: 35px;"><?php the_title(); ?></h1>
                            <h1 style="color: #0D3D62;margin-top:0;margin-bottom:25px;line-height: 50px;font-size: 50px;"><?php echo $cfs->get('duration_of_training'); ?></h1>
                            <?php the_content(); ?>
                            <button style="margin-bottom:20px;float:right;">BOOK NOW</button>
                            <button class="md-close" style="">Close me!</button>
                        </div>
                    </div>
                </div>

                <div class="md-overlay"></div><!-- the overlay element -->

                    <?php endwhile; wp_reset_query();?>
            </ul>

inside < li > < /li > there is a button when clicked will show the md-content

But when i click the button on any post displayed, it shows the same content on all posts of the first displayed post.

I am using this pop tutorial for it http://tympanus.net/codrops/2013/06/25/nifty-modal-window-effects/

share|improve this question
    
Your code doesn't show where the $cfs object is defined. Does the_title() output the same or different values for each post in the loop? –  Chip Bennett Nov 20 '13 at 14:39
    
Hi $cfs is a custom field created by using a plugin, Yes the title are showing different. –  luckyrajiv Nov 20 '13 at 14:49
    
If the Titles are showing differently, then the loop is functioning properly. Your problem is with the $cfs object. Please add its relevant code to your question, or else we have no way to help resolve the problem. –  Chip Bennett Nov 20 '13 at 14:50
    
even that is working properly. Its the content inside md-modal,which is showing same on all posts –  luckyrajiv Nov 20 '13 at 14:50
    
Are both instances of the_title() outputting properly, or only the one outside the modal? –  Chip Bennett Nov 20 '13 at 14:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.