Create Read More Popups for Posts
Adding WordPress Post Previews Inside a Popup
In the current iteration of Popup Maker, doing this requires some custom code, and this guide is going to present that code so you can have your post preview in your modals!
So, wherever you want you’re Post Preview to be displayed in a popup with a read more link, you can modify your themes existing template and Loop to include something like this.
CODE AHEAD: This is an example, and customizing this to fit your existing theme template will require a basic knowledge of PHP.
<?php while ( have_posts() ) : the_post();?> <article> <h2><a class="popmake-post-<?php the_ID();?>" href="<?php the_permalink();?>"><?php the_title();?></a></h2> <?php echo do_shortcode("[popup id='post-". get_the_ID() ."' size='small' title='". get_the_title() ."']". get_the_content() . "[/popup]");?> </article> <?php endwhile; ?>
This loop includes the [popup] shortcode, so it creates the popups on the fly, and they will be created dynamically for all posts in this Loop. Simply replace your current loop with this modified version and it will work out-of-the-box!
Customizing to fit your theme is to be expected.
- You can use the shortcode to dynamically make popups anywhere in a while/for type loop or the WordPress Loop.
- The only required attribute for the [popup] shortcode is the id.
- The id in the shortcode is also used in the form of “popmake-id” as a class on the element that will Trigger that popup to open.