Wordpress较旧的帖子页面错误

时间:2016-02-19 20:40:34

标签: php wordpress

我的自定义wordpress模板存在问题。

我已经制作了一个分类页面。在第一视图上工作正常。 但是当我点击第二页上的旧帖子时,浏览器会显示404错误。

我认为我的查询需要更多内容,但我不知道这是什么或者是否是问题。

有人可以帮忙吗?

这是我的代码:

<?php
/**
 * The template for displaying Category pages
 */
?>
<?php get_header(); ?>

<?php get_template_part( 'partials/linea-content', 'page' ); ?>

<div class="index categories">
    <div class="col-xs-12 pre-content">
        <div class="container">
            <?php //Para añadir contenido se interesa ?>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-xs-12 categories-title">
                <h2>Categoria: <span><?php echo get_category(get_query_var('cat'))->name; ?></span></h2>
            </div>
            <div id="posts" class="col-xs-12 col-sm-9">
                <?php
                    // set the "paged" parameter (use 'page' if the query is on a static front page)
                    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

                    // Cambiamos los argumentos para buscar desde la última
                    $args = array(
                                    'posts_per_page' => 2,
                                    'orderby' => 'date',
                                    'order' => ASC,
                                    'category__in' => get_category(get_query_var('cat'))->cat_ID,
                                    'paged' => $paged
                                );
                    // '&orderby=date&order=ASC&category=' . get_category(get_query_var('cat'))->cat_ID;

                    // volvemos a crear la consulta principal
                    $aux = query_posts( $args );

                    $cont_items = 1;
                ?>
                <?php if ( have_posts() ) : ?>
                    <div class="row items-row">
                        <div class="col-xs-12">
                        <?php while ( have_posts() ) : the_post(); ?>

                            <!-- post -->                            
                            <div id="post-id-<?php echo $post->ID; ?>" class="item col-xs-12 col-sm-6">
                                <div class="row">
                                    <div class="col-xs-12 text-center item-content">
                                        <span class="meta-category">
                                            <span class="meta-category-inner">
                                                <?php
                                                    $cat = get_the_category($post->ID);
                                                ?>
                                                <a href="<?php echo get_category_link($cat[0]->cat_ID); ?>" rel="category tag"><?php echo $cat[0]->name; ?></a>
                                            </span>
                                        </span>

                                        <?php
                                            global $wpdb;
                                            $ppbv_tablename = $wpdb->prefix . 'popular_by_views';
                                            $currentRow = $wpdb->get_row("SELECT * FROM {$ppbv_tablename} WHERE post_id = {$post->ID}");
                                            $curView = 0;

                                            if(isset($currentRow))
                                            {
                                                $curView = $currentRow->views;
                                            }
                                        ?>
                                        <div class="item-title-content">
                                            <a href="<?php the_permalink(); ?>" title="Popsicase">
                                                <h2 class="item-title col-xs-10 col-xs-offset-1"><?php the_title(); ?></h2>
                                            </a>
                                        </div>
                                        <p class="date-cat">
                                            <small class="col-xs-12">
                                                <a href="<?php the_author(); ?>" title=""><i class="fa fa-link"></i> <strong><?php the_author(); ?></strong></a>&nbsp;|&nbsp;<span><i class="fa fa-calendar"></i> <?php echo get_the_date();?>&nbsp;|&nbsp;<i class="fa fa-eye"></i> <?php echo $curView; ?></span>
                                            </small>
                                        </p>

                                        <?php
                                            $img_url = get_template_directory_uri() . '/assets/img/podcast.jpg';

                                            if (get_the_post_thumbnail())
                                            {
                                                $img_url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
                                            }
                                        ?>
                                        <a href="<?php the_permalink(); ?>" title="Popsicase">
                                            <div class="item-thumbnail" style="background:url(<?php echo $img_url; ?>) no-repeat center center;">
                                            </div>
                                        </a>

                                        <div class="row">
                                            <div class="col-xs-6 text-right">
                                                <?php /*<span class="comment"> Comentarios: <?php comments_number( '0','1','%'); ?></span>*/ ?>
                                            </div>
                                        </div>
                                        <div class="item-excerpt text-left">
                                            <div class="col-xs-12">
                                                <?php the_excerpt(); ?>
                                            </div>  
                                        </div>
                                    </div>
                                </div>
                            </div>

                    <?php if ($cont_items % 2 == 0) : ?>
                            </div>
                        </div>
                        <div class="row items-row">
                            <div class="col-xs-12">
                    <?php
                            endif;

                            $cont_items++;
                        ?>
                        <?php endwhile; ?>
                        </div>
                    </div>
                <!-- End of the main loop -->

                <!-- Add the pagination functions here. -->
                <?php
                    the_posts_pagination( array(
                        'mid_size' => 4,
                        'prev_text' => __( 'Artículos antiguos', 'textdomain' ),
                        'next_text' => __( 'Artículos nuevos', 'textdomain' ),
                    ) );
                ?>

                <?php /*
                <div class="nav-previous alignleft"><?php next_posts_link( 'Artículos antiguos' ); ?></div>
                <div class="nav-next alignright"><?php previous_posts_link( 'Artículos nuevos' ); ?></div>
                */ ?>

                <?php else : ?>
                <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
                <?php endif; ?>
            </div>
            <div class="hidden-xs col-sm-3 sidebar">
                <div class="row">
                    <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('main-sidebar')) : ?>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
    <div class="col-xs-12 pos-content">
        <div class="container">
            <?php //Para añadir contenido se interesa ?>
        </div>
    </div>
    <div class="clearfix"></div>
</div>

0 个答案:

没有答案