• Hi,

    Does anyone have experience getting posts to open in a popup when clicked from the archive page?

    I have a custom post type archive that displays the Title and Featured Images for each of the posts in a gallery. When the visitor clicks on the image, I need the single post content (text and the featured image) to open in a popup window, rather than opening a new page.

    I tried using the jQuery Popup Overlay jq plugin, with the_content() wrapped in a div that gets targeted for the popup. But it didn’t work.

    Here (basically) is the code I used in my template (the href is supposed to trigger the #my_popup div):

    <?php $loop = new WP_Query(
        array(
            'post_type' => 'facilities',
            'posts_per_page' => -1
        )
    ); if ($loop->have_posts()) : ?>
        <div class="gallery-container">
            <div class="gallery">
                <?php while ($loop->have_posts()) : $loop->the_post(); ?>
                    <a href="#my_popup">
                        <?php the_post_thumbnail(); ?>
                    </a>
                    <h2><?php the_title(); ?></h2>
                    <div id="#my_popup">
                        <?php the_content(); ?>
                    </div>
                <?php endwhile; ?>
            </div>
        </div>
    <?php endif; wp_reset_postdata(); ?>

    I think the problem is that the jQuery Popup Overlay plugin doesn’t allow you to target multiple divs (since it’s triggered based on the id). My js/jq skills are fairly basic though, so I may just be missing something.

    I’ve been searching around for alternative approaches and haven’t found anything else that does what I need. All the popup scripts I did find (including WordPress plugins) seem to only work for images/video, or if they do work for text content you have to enter it manually through plugin options.

    Any ideas?

  • The topic ‘How to open posts in a popup overlay?’ is closed to new replies.