Php 二十一世纪主题中的样式分页
我使用WordPress二十一主题作为父主题。我想在其中添加编号分页,因此我找到了这段代码,并将其添加到function.php文件中:Php 二十一世纪主题中的样式分页,php,css,wordpress,pagination,Php,Css,Wordpress,Pagination,我使用WordPress二十一主题作为父主题。我想在其中添加编号分页,因此我找到了这段代码,并将其添加到function.php文件中: <?php endif; ?> 问题是我没有添加css样式,因为它在任何ID或类中都没有扭曲,这限制了我按照计划的方式设置样式的能力。是否有任何方法可以将类或Id添加到此代码中,以便我可以对其进行样式设置 我已经检查了Wordpress编解码器,无法在paginate_links函数中添加类或id 为什么不将echo语句包装在容器div中 ?>
<?php
endif;
?>
问题是我没有添加css样式,因为它在任何ID或类中都没有扭曲,这限制了我按照计划的方式设置样式的能力。是否有任何方法可以将类或Id添加到此代码中,以便我可以对其进行样式设置 我已经检查了Wordpress编解码器,无法在paginate_links函数中添加类或id 为什么不将echo语句包装在容器div中
?><div class="paginated-links"><?php
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
?></div><?php
谢谢,我不知道我该怎么处理你的代码段。我已经编辑了我的答案,用代码来替换我的代码。我可能听起来像个傻瓜,但还是不明白!你是否建议用你的代码替换(在my functions.php文件中)添加编号分页的代码,或者我遗漏了什么?好的,这是你的代码:,用以下代码替换它:在you functions.php文件中。谢谢你!但这只会触发默认设置(较新和较旧的帖子导航)
?><div class="paginated-links"><?php
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
?></div><?php
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
<?php $category = get_category( get_query_var( 'cat' ) );
$cat_id = $category->cat_ID;
?>
<?php
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wpquery = new WP_Query(array(
'order' => 'DESC',
'cat' => $cat_id,
'posts_per_page' => 10,
'paged'=>$page
));
while ($wpquery->have_posts()) {
$wpquery->the_post();
?>
<li class="contentlist">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><a href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a></p>
</li>
<?php
}
?>
<?php
global $wpquery;
if( $wpquery->max_num_pages >1){
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wpquery->max_num_pages
) );
}
?>
// Pagination for each category
function custom_ppp( $query ) {
if ( !is_admin() && $query->is_category() && $query->is_main_query() ) {
$query->set( 'posts_per_page', '10' );
}
}
add_action( 'pre_get_posts', 'custom_ppp' );
?>