我試圖使用光滑滑塊作爲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,而無需刷新頁面與幻燈片一起更新。有什麼辦法可以做到這一點?