我试图使用光滑滑块作为WordPress单个CPT页面上的上一个和下一个按钮。使用光滑滑块作为WP Post导航
因此,滑块将调用特定CPT的所有帖子,并显示当前帖子的精选图片,并在任一侧显示前一帖和下一帖的精选图片。
当您浏览幻灯片时,会出现相应的内容。
问题是,当你滑过你会得到正确的图像和内容,但网址保持不变。此外,您无法链接到特定的帖子,因为它只会转到幻灯片的开头。
现在,这是我的single-CPT.php
是什么样子
<?php
get_header();
rewind_posts();
if (have_posts()) {
while (have_posts()) : the_post();
$post_id = get_the_ID();
?>
// BEGIN SLIDER (WHERE FEATURED IMAGES ARE THE SLIDES)//
<section class="slider center">
<?php
$index = 0;
$carousel_args = array(
'post_type' => 'CPT',
'posts_per_page' => -1,
);
$carousel_query = new WP_Query($carousel_args);
if ($carousel_query->have_posts()) {
while ($carousel_query->have_posts()) {
$carousel_query->the_post();
$title = get_the_title();
$link = get_permalink();
if (has_post_thumbnail()) {
$post_thumbnail_id = get_post_thumbnail_id();
$post_thumbnail_image = wp_get_attachment_image_src($post_thumbnail_id, 'large');
$post_thumb = $post_thumbnail_image[0];
} else {
$post_thumb = '';
}
$content = get_the_content();
$excerpt = get_the_excerpt();
// output//
?>
<div class="wow slide-in slide">
<div class="active">
<a href="<?php echo $link; ?>">
<img src="<?php echo $post_thumb; ?>" />
</a>
</div>
</div>
<?php $index++;
}
}
wp_reset_postdata();
endwhile;
?>
</section>
//END SLIDER - BEGIN CONTENT//
<div id="archive-post">
<div class="row">
<div class="columns small-12 medium-10 medium-offset-1 large-offset-0 large-8">
<article id="post-<?php the_ID(); ?>" role="article">
<div class="post-title">
<div class="row">
<div class="columns">
<h3><?php the_title(); ?></h3>
</div>
</div>
</div>
<div class="post-content">
<div class="row">
<div class="columns">
<?php the_content(); ?>
</div>
</div>
</div>
</article>
</div>
</div>
</div>
基本上我需要的URL,而无需刷新页面与幻灯片一起更新。有什么办法可以做到这一点?