Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLinda Shum
12,609 PointsPossible to populate the modal window with content for a post (clicked link)?
I have a page of blog post links and when I click one instead of going to a permalink and to a single.php template I would like it to open the post in a modal window with a close button like the contact form window.
How do I capture and pass the post ID from the link to the modal window so that I can show the correct post content?
BTW I am using the loop below to display the links on the original page.
[code]
<div class="cd-projects-wrapper"> <ul class="cd-slider"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <li class="current"> <a href='#'> <img src='/portfolio/assets/img.png' alt='project image'> <div class='project-info'> <h2><a href="#" class="link" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2> <p>Description of project <?php echo $post_id; ?></p> </div> </a> </li>
<?php endwhile;endif; ?>
</ul> <!-- .cd-slider-navigation -->
</div> <!-- .cd-projects-wrapper -->
[/code]
1 Answer
Luis Felipe Lino
Full Stack JavaScript Techdegree Student 15,708 PointsHi Linda. I guess that what you want to do is a little bit harder because you will need to work with ajax requests. See if you want something like this.
Here you can see how to do it. To be honest I did not tried this example yet, but I guess it's working well, or at least can help you to get closer where you want.