You can achieve that functionality by loading your template in a hidden div with z-index greater than that of a overlay div. now when clicked on any image you can use jquery to show the hidden div and the overlay. The overall process can be summarized as below:
-
Create a overlay div anywhere in your page(say home page).Suggested to be below your footer as below:
<?php get_footer();?> <div id="overlay"></div>
-
The css for the overlay would be like this:
#overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #000; filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.5; display:none; z-index: 1000; }
-
Now create a hidden div that will load your template as below in your page:
<div class="myclass" style="z-index:1001;display:none;"><?php load_template('path_to_your_template_you_want_to_load.php'); ?></div> <a class="click_img"><img src="https://wordpress.stackexchange.com/questions/126590/url to image you want to show" /></a>
-
Now include a script that will show your hidden div when clicked on the image as below:
jQuery(document).ready(function(e) { jQuery('.click_img').click(function(e){ e.preventDefault(); var winY = jQuery(document).scrollTop(); var y = 1.04*winY; var winX = jQuery(window).width(); jQuery('#overlay').show(); jQuery('.myclass').show(); jQuery('.close_button').show(); }); }); jQuery('.close_button,#overlay').click(function(e){ jQuery('.myclass').hide(); jQuery('#overlay').hide(); jQuery('.close_button').hide(); }); });
-
Now note that the close button in your template to be loaded must have the class close_button.
<div class="close_button"></div>
- Now it’s up to you to design your close button.