0
嗨,我是WordPress開發新手。我創建了一個自定義帖子類型的「項目」,其中顯示了項目列表。我想在其單個頁面(single-project.php)中放置一個「返回項目」按鈕,該按鈕將重定向回其列表頁面。我怎樣才能做到這一點?看代碼中的最後一行。請幫忙。重定向到其單頁上的頁面
if ($query->have_posts()):
while ($query->have_posts()):
$query->the_post();
?>
<div class="related-project-single">
<?php the_post_thumbnail('image_size_720_680'); ?>
<div class="wrapper-button">
<a class="bp-button bp-button-plain button-yellow btn-slider" href="<?php the_permalink(); ?>"><?php echo esc_html__('view project','inspiry') ?> <i class="fa fa-chevron-right"></i></a>
</div>
<div class="wrapper-location">
<h3><?php the_title(); ?></h3>
<?php
$feature_location_related = get_post_meta(get_the_ID(),'bp-location',true);
if(!empty($feature_location_related)){
?>
<p class="featured-location"><?php echo esc_html($feature_location_related);?></p>
<?php
}
?>
</div>
</div>
<?php
endwhile;endif;?>
<a href="">Back to projects</a>
除非他的列表分頁,然後它會去的第一個每次。 如果它被分頁,他可以將頁碼保存在一個會話中,並從中創建一個變量,所以像這樣:href =「index.php/projects/<?php echo $ pageNumber?>」(取決於鏈接結構) – Stender