如何在服装贴纸字体上使用分页

时间:2019-01-20 作者:saul

我使用插件costum post type UI制作了一个costum post type

我试图在主页/索引上显示i

密码

<?php args1 = array( \'post_type\' => \'app\', \'posts_per_page\' => 3 );$the_query1 = new WP_Query( $args1 );
// The Loop
if ( $the_query1->have_posts() ) {
while ( $the_query1->have_posts() ) : $the_query1->the_post(); ?>
    <h1><a href="<?php the_permalink();?>"><?php the_title();?></a></h1>
    <?php
endwhile;
wp_reset_postdata();
} else {
echo "no post found"; }?>
那么,如何显示分页??

thank\'s

*对不起,我的英语不好

1 个回复
SO网友:Deepak Kumar
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1; $args = array( \'post_type\'=>\'post\', // Your post type name
\'posts_per_page\' => 6,
\'paged\' => $paged,); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post(); // YOUR CODE
endwhile;
$total_pages = $loop->max_num_pages;
if ($total_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\' => $total_pages,
        \'prev_text\'    => __(\'« prev\'),
        \'next_text\'    => __(\'next »\'),
    ));
}} wp_reset_postdata();

相关推荐

change pagination url

目前,我的分页页面URL为:http://www.example.com/category_name/page/2但我需要将此URL结构更改为:http://www.example.com/category_name/?page=2等有什么解决方案吗?