我正在创建单页WP主题,实际上主题是由我将其转换为WP的其他人创建的。一切正常,但当博客部分的帖子被查看和关闭时,所有的轮播在网站上都会中断。帖子以夸张的弹出方式打开。
//链接
<a href="<?php the_permalink(); ?>" class="ajax-popup-link"></a>
// magnific
$('.ajax-popup-link').magnificPopup({ type: 'ajax', closeOnBgClick: false });
//使用弹出窗口
的完整代码 <?php
$bl_args = array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DEC',
);
$counter = 0;
$bl_query = new WP_Query( $bl_args );
// The Loop
if ( $bl_query->have_posts() ) {
while ( $bl_query->have_posts() ) {
$bl_query->the_post();
if( $counter%4 == 0 ) {
echo '<div class="blog">';
echo '<div class="row">';
} //open before every fourth item
echo '<div class="col-md-6">';
?>
<a href="<?php the_permalink(); ?>" class="ajax-popup-link">
<?php
the_post_thumbnail('blog-thumb');
?>
</a>
<?php
echo '<div class="row">';
echo '<div class="col-sm-2"><span><span>';
the_time('j');
echo '</span>';
the_time('F Y');
echo '</span>';
echo '</div><!-- .col-sm-2 -->';
echo '<div class="col-sm-10">';
echo '<h4>';
?>
<a href="<?php the_permalink(); ?>" class="ajax-popup-link">
<?php
echo get_the_title();
?>
</a>
<?php
echo '</h4>';
the_excerpt();
echo '</div><!-- .col-sm-10 -->';
echo '</div><!-- .row -->';
echo '</div><!-- .col-md-6 -->';
if( $counter%4 == 3 ) {
echo '</div><!-- .row -->';
echo '</div><!-- .blog -->';
} //close after each block of four or after last item
$counter++;
}
}
/* Restore original Post Data */
wp_reset_postdata();
?>
谢谢!
答案 0 :(得分:0)
问题是因为弹出窗口,样式和脚本再次加载。我删除了wp_head()
和wp_footer()
,现在一切都很顺利。