Php .当我在WordPress站点中单击分页时,当前类未更改
我没有找到任何方法来解决这类错误。我在我的wordpress网站上添加了一个分页。一切都正常。但当我点击2、3、4…等页面时,它并没有改变它的类Php .当我在WordPress站点中单击分页时,当前类未更改,php,css,wordpress,pagination,Php,Css,Wordpress,Pagination,我没有找到任何方法来解决这类错误。我在我的wordpress网站上添加了一个分页。一切都正常。但当我点击2、3、4…等页面时,它并没有改变它的类。current,这就是为什么它没有得到。current类的css 多媒体资料的功能代码: function jellythemes_gallery($atts, $content=null) { extract( shortcode_atts( array( 'limit' => -1 ), $atts )
。current
,这就是为什么它没有得到。current
类的css
多媒体资料的功能代码:
function jellythemes_gallery($atts, $content=null) {
extract( shortcode_atts( array(
'limit' => -1
), $atts ) );
global $post;
$back=$post;
echo '<div id="portfolio">
<div class="section portfoliocontent">
<section id="i-portfolio" class="clear">';
// set up or arguments for our custom query
$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
$query_args = array(
'post_type' => 'media',
'posts_per_page' => 12,
'paged' => $paged
);
// create a new instance of WP_Query
$the_query = new WP_Query( $query_args );
if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
$image = get_post_meta( $post->ID, '_jellythemes_media_photo', true );
$video = get_post_meta( $post->ID, '_jellythemes_media_video', true );
$img = wp_get_attachment_image_src($image, 'media_thumb');
echo '<div class="ch-grid element">
<img class="ch-item" src="' . $img[0] .'" alt="' . get_the_title() . '" />';
if (empty($video)) {
echo '<a class="fancybox img-lightbox" rel="" href="' . $img[0] .'">';
} else {
echo '<a class="fancybox-media" rel="" href="' . $video.'">';
}
echo '<div>
<span class="p-category ' . (empty($video) ? 'photo' : 'video') . '"></span>
</div>
</a>
</div>';
endwhile;
$post=$back; //restore post object
$return .= '</section>
</div>
</div>';
echo "<div class='pagination_center'>";
if ($the_query->max_num_pages > 1) {
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/page/%#%',
'current' => $current_page,
'total' => $the_query->max_num_pages,
'show_all' => true,
'prev_text' => __('« PREV'),
'next_text' => __('NEXT »'),
'prev_next' => false,
));
}
else{
echo '<article>
<h1>Sorry...</h1>
<p>';echo 'Sorry, no posts matched your criteria.'; echo'</p>
</article>';
}
endif;
echo "</div>";
return $return;
}
add_shortcode( 'jellythemes_gallery', 'jellythemes_gallery' );
.pagination_center .current{
border: 1px solid #c3121c;
padding: 0px 5px;
color: black;
font-weight: bold;
background: #c3121c;
}
在这里,我添加了一个with inspect元素。它是第2页,但在第1页上是。当前的类。有人能告诉我问题出在哪里吗
提前谢谢。如果您需要进一步的代码,请告诉我。您需要在下一页替换您的基本代码。问题可能是%\uu%
和%\u35;%
并且在没有测试的情况下,它似乎没有什么帮助。但是试试下面的代码
$big = 999999999; // need an unlikely integer
echo paginate_links(array(
'base' => str_replace($big, '%#%', esc_url( get_pagenum_link($big) ) ),
'format' => '/page/%#%',
'current' => $current_page,
'total' => $the_query->max_num_pages,
'show_all' => true,
'prev_text' => __('« PREV'),
'next_text' => __('NEXT »'),
'prev_next' => false,
));
这可能对你有帮助。另请参阅更多信息,了解下一页需要更换底座的信息。问题可能是%\uu%
和%\u35;%
并且在没有测试的情况下,它似乎没有什么帮助。但是试试下面的代码
$big = 999999999; // need an unlikely integer
echo paginate_links(array(
'base' => str_replace($big, '%#%', esc_url( get_pagenum_link($big) ) ),
'format' => '/page/%#%',
'current' => $current_page,
'total' => $the_query->max_num_pages,
'show_all' => true,
'prev_text' => __('« PREV'),
'next_text' => __('NEXT »'),
'prev_next' => false,
));
这可能对你有帮助。另请参阅更多信息,了解我也遇到了同样的问题,并在调试分页代码时修复了它。
以下是分页在静态首页中工作的解决方案。
替换
与
在WP_查询循环中
那么你需要换一个
'current' => $current_page,
与
在分页链接数组中
对我来说,它就像一个符咒。你也应该试试这个。我确信它能100%工作。我也遇到了同样的问题,并在调试分页代码时修复了它。
以下是分页在静态首页中工作的解决方案。
替换
与
在WP_查询循环中
那么你需要换一个
'current' => $current_page,
与
在分页链接数组中
对我来说,它就像一个符咒。你也应该试试这个。我确信它能100%工作。你能给我们看一下分页代码吗plz@ChoncholMahmud:你添加类的JS代码在哪里?你能在这里阅读答案吗?@YoYo我想。当前的是wordpress类。我没有为这个类添加任何JS。你能为2,3,4的onclick粘贴函数吗,等等?你能给我们看看分页代码吗plz@ChoncholMahmud:你添加类的JS代码在哪里?你能在这里阅读答案吗?@YoYo我想。当前的是wordpress类。我没有为这个类添加任何JS。你能粘贴2、3、4等的onclick函数吗?我已经测试过了,但没有工作.current
类在第1页中。完全没有更改。第$current\u page
行$current\u page=max(1,获取查询变量('paged'))后的$current\u page
值是多少
是否递增。分页更改其值,但不更改类。current
一个接一个。我已看到您的站点。您需要使用print\r为每个页面传递paginate\u links
函数的数组进行调试。我已经测试过了,但不起作用.current
类在第1页中。完全没有更改。第$current\u page
行$current\u page=max(1,获取查询变量('paged'))后的$current\u page
值是多少
是否递增。分页更改其值,但不更改类。current
一个接一个。我已看到您的站点。您需要使用print\r为每个页面传递paginate\u links
函数的数组进行调试。
'current' => max( 1, $paged ),