分页时将锚点添加到第 1 页上一个来自第 2 页的链接

我使用以下内容进行分页:


<?php endwhile;

     echo "<div class='paginate_wrap'>";

     echo paginate_links ( array (

          'add_fragment' => '#project_area',

          'format' => '?paged=%#%',

          'current' => max( 1, get_query_var('paged') ),

           'total' => $related->max_num_pages,

           'prev_text' => '',

           'next_text' => ''

     ) );

     echo "</div>";

     endif; ?>

#project-area 用于将用户向下滚动到页面的所需部分。


当用户位于第 2 页时,此功能可以接受,并点击后退箭头转到第 1 页。当前,此超链接指向基本 URL,而没有附加所需的 #project_area。


我需要更改什么才能仅从第 2 页上的上一个超链接将 #project_area 添加到第 1 页 URL,而不应用 ?paged=1?


交互式爱情
浏览 90回答 1
1回答

喵喔喔

尝试使用 'base' 参数&nbsp; &nbsp; $big = 999999999;&nbsp; &nbsp; echo paginate_links ( array (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'base' => str_replace( $big, '%#%', get_pagenum_link( $big, false ) ),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'add_fragment' => '#project_area',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'format' => '?paged=%#%',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'current' => max( 1, get_query_var('paged') ),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'total' => $related->max_num_pages,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'prev_text' => '',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'next_text' => ''&nbsp; &nbsp; &nbsp;) );&nbsp; &nbsp; &nbsp;echo "</div>";
打开App,查看更多内容
随时随地看视频慕课网APP