wordpress 类别分页不再起作用 [英] wordpress category pagination not working anymore

查看:39
本文介绍了wordpress 类别分页不再起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的导航停止处理我的自定义帖子类别...我有这个:

My navigation stoped working on my custompost category... i have this :

文件夹

<?php $loop = new WP_Query( array( 'post_type' => 'portfolios', 'posts_per_page' => 8, 'offset'=> 0 ,'paged' => $paged,  ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

    <li class="list_c">  


<a href="<?php the_permalink(); ?>"><div><div id="over2"><p>+info</p></div></div>
<div id="read"> <span>ler mais </span></div>


<div id="ptxL" class="filldiv">

<div id="thumbL" class="grow "><?php the_post_thumbnail('featuredImageCropped3');?></div> 

<div id="infoL">

<div id="titled" class="tt">

<h2><?php the_title();?></h2></div>

<div id="contentL"><h3><?php the_excerpt(); ?> </h3></div></div><div id="color"></div>

<!-- You have not associated any custom fields with this post-type. Be sure to add any desired custom fields to this post-type by clicking on the "Manage Custom Fields" link under the Custom Content Type menu and checking the fields that you want. -->

</div></a></li>




<?php endwhile; wp_reset_query(); ?>



<?php wpbeginner_numeric_posts_nav(); ?>


<?php get_footer(); ?> 

和我的functions.php:

and on my functions.php:

function wpbeginner_numeric_posts_nav() {

    if( is_singular() )
        return;

    global $wp_query;

    /** Stop execution if there's only 1 page */
    if( $wp_query->max_num_pages <= 1 )
        return;

    $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
    $max   = intval( $wp_query->max_num_pages );

    /** Add current page to the array */
    if ( $paged >= 1 )
        $links[] = $paged;

    /** Add the pages around the current page to the array */
    if ( $paged >= 3 ) {
        $links[] = $paged - 1;
        $links[] = $paged - 2;
    }

    if ( ( $paged + 2 ) <= $max ) {
        $links[] = $paged + 2;
        $links[] = $paged + 1;
    }

    echo '<div class="navigation"><ul>' . "\n";

    /** Previous Post Link */
    if ( get_previous_posts_link() )
        printf( '<li class="pre">%s</li>' . "\n", get_previous_posts_link() );

    /** Link to first page, plus ellipses if necessary */
    if ( ! in_array( 1, $links ) ) {
        $class = 1 == $paged ? ' class="active"' : '';

        printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );

        if ( ! in_array( 2, $links ) )
            echo '<li>…</li>';
    }

    /** Link to current page, plus 2 pages in either direction if necessary */
    sort( $links );
    foreach ( (array) $links as $link ) {
        $class = $paged == $link ? ' class="active"' : '';
        printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
    }

    /** Link to last page, plus ellipses if necessary */
    if ( ! in_array( $max, $links ) ) {
        if ( ! in_array( $max - 1, $links ) )
            echo '<li>…</li>' . "\n";

        $class = $paged == $max ? ' class="active"' : '';
        printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
    }

    /** Next Post Link */
    if ( get_next_posts_link() )
        printf( '<li>%s</li>' . "\n", get_next_posts_link() );

    echo '</ul></div>' . "\n";

}

我更换了服务器,也许这就是问题所在......但我可以让它工作......我的调试没有发现任何错误......

i changed servers maybe thats the problem...but i can make it work...my debug finds no errors...

推荐答案

请试试这个代码.我认为你的分页参数有误.

Please try this code.I think you have mistake in paged parameter.

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_type' => 'portfolios', 'posts_per_page' => 8, 'offset'=> 0 ,'paged'=>$paged  ) ); ?>
query_posts($args);
 if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li class="list_c">  
<a href="<?php the_permalink(); ?>"><div><div id="over2"><p>+info</p></div></div>
<div id="read"> <span>ler mais </span></div>


<div id="ptxL" class="filldiv">

<div id="thumbL" class="grow "><?php the_post_thumbnail('featuredImageCropped3');?></div> 

<div id="infoL">

<div id="titled" class="tt">

<h2><?php the_title();?></h2></div>

<div id="contentL"><h3><?php the_excerpt(); ?> </h3></div></div><div id="color"></div>

<!-- You have not associated any custom fields with this post-type. Be sure to add any desired custom fields to this post-type by clicking on the "Manage Custom Fields" link under the Custom Content Type menu and checking the fields that you want. -->

</div></a></li>
<?php endwhile;endif; ?>
<?php wpbeginner_numeric_posts_nav(); ?>
<?php wp_reset_query(); ?>

我希望这对你有用.谢谢

I hope this will work for you. Thanks

这篇关于wordpress 类别分页不再起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆