给你。谷歌没有使用JS,也没有花哨。链接也可以不使用get,只使用简单的url:page。com/post名称/
在单页上:
<?php
$apost = $_GET["type"];
preg_replace(\'/_/\', \'html\', preg_replace(\'/%/\', \'html\', htmlentities(mysql_real_escape_string($apost))));
?>
<?php if($apost == \'iframe\') { ?>
<?php get_header(\'single\'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div class="popup people">
staff of popup
</div>
<?php endwhile; endif; ?>
</body>
</html>
<?php } else { ?>
<?php get_header(); ?>
<div class="single">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
staff of content
<?php endwhile; endif; ?>
</div>
<?php get_footer(); ?>
<?php } ?>
在html按钮或链接等上:
<a href="<?php the_permalink();?>#<?php the_ID(); ?>" data-fancybox-type="iframe" class="various" id="<?php the_ID(); ?>" data-class="<?php echo get_post_type( get_the_ID() ); ?>">View item</a>
在javascript中:
$(".results .results_item a").each(function(){
var hrefParts = $(this).attr(\'href\').split(\'#\');
$(this).attr(\'href\', hrefParts[0] + \'?type=iframe#\' + hrefParts[1]);
});
$("a").fancybox({
maxWidth : 615,
maxHeight : 2000,
fitToView : true,
width : \'100%\',
height : \'100%\',
autoSize : false,
closeClick : false,
openEffect : \'none\',
closeEffect : \'none\',
wrapCSS : \'people\' // add a class selector to the fancybox wrap
});
$("a").click(function(event) {
window.location.hash = this.hash;
});
if(window.location.hash) {
var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character
var new_class_name = $("#" + hash).data("class");
$("#" + hash).fancybox({
maxWidth : 615,
maxHeight : 2000,
fitToView : true,
width : \'100%\',
height : \'100%\',
autoSize : false,
closeClick : false,
openEffect : \'none\',
closeEffect : \'none\',
wrapCSS : new_class_name // add a class selector to the fancybox wrap
}).trigger(\'click\');
// hash found
} else {
// No hash found
}