【发布时间】:2013-06-06 11:07:53
【问题描述】:
您好,我需要为 wordpress 网站创建一个简单的弹出功能。
我的循环正在运行并正确显示帖子。单击后发布应出现在弹出窗口中。我到目前为止所得到的。除了添加 fancybox 来完成它的工作。
<a class="modalbox" rel="<?php echo $post->ID; ?>" href=" http://localhost/makijaz/?page_id=12">
<article> ...Wordpress post </article>
我从其他线程得到了下面的那个,但它不起作用。
$(".modalbox").on("click", function() {
var postId = $(this).prop("rel");
$(this).fancybox();
});
href in 指向带有其他循环的模板页面。需要简单地对 PostID (它在 rel 中)进行 gram 并将其放入其他循环中以显示在弹出窗口中。
<?php
/*
Template Name: Ajax Post Handler
*/
?>
<?php
$post = get_post($_GET['id']);
?>
<?php if ($post) : ?>
<?php setup_postdata($post); ?>
<div class="whatever">
<h2 class="entry-title"><?php the_title() ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
</div>
<?php endif; ?>
希望我已经说清楚了。
【问题讨论】:
标签: php wordpress popup fancybox