使用自定义帖子类型的分页在index.php上不起作用:我得到一个404

时间:2013-12-22 作者:slwr

我读过很多关于同一问题的帖子,但似乎没有一篇对我有用。

我在索引中查询了一个自定义帖子。php。当我转到第2页时,我得到一个404错误。相同的代码在任何静态页面中都像一个符咒一样工作。

<?php get_header(); ?>
            <div id="content">
                <div id="inner-content" class="wrap clearfix">
                    <div id="main" class="clearfix main-index" role="main">
                        <h5 class="mini-title">Latest Works Added</h5>
                        <?php wp_reset_query();?> 
                        <?php 
                        // the query
                        $args = array(\'post_type\' => \'work\', \'posts_per_page\' => 2, \'paged\' => $paged);
                        $the_query = new WP_Query( $args ); 
                        ?>

                        <?php if ( $the_query->have_posts() ) : ?>

                        <!-- pagination here -->

                        <!-- the loop -->
                        <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                            <article id="post-<?php the_ID(); ?>" class="fourcol home-article" role="article">
                                <a href="<?php echo the_permalink();?>">
                                    <table class="table">
                                        <tbody>
                                            <tr>
                                                <td><h3>Title</h3></td>
                                                <td><h3><?php the_title(); ?></h3></td>
                                            </tr>
                                            <tr>
                                                <td><h3>Author</h3></td>
                                                <?php
                                                require_once\'wp-content/themes/p-dpa/rdfa/lib/arc2/ARC2.php\';
                                                include_once(\'wp-content/themes/p-dpa/rdfa/connect_to_store.php\');

                                                // All Artists                      
                                                $query = \'
                                                    PREFIX dcterms: <http://purl.org/dc/terms/> 
                                                    PREFIX foaf: <http://xmlns.com/foaf/0.1/>
                                                    SELECT distinct ?url ?name 
                                                    WHERE   {
                                                        <\'.get_permalink().\'> dcterms:creator ?url .
                                                        ?url foaf:name ?name
                                                    }
                                                \';
                                                $result = $store->query($query, \'rows\');
                                                if (!empty($result)) {
                                                    echo \'<td><h3>\';
                                                    $names = array();
                                                    foreach ($result as $row) {
                                                        array_push($names, $row[\'name\']);
                                                    }
                                                    echo implode(\', \', $names);
                                                }
                                                echo \'</h3></td>\';
                                                ?>
                                            </tr>
                                            <?php
                                            $first_image = catch_that_image();
                                            if ($first_image != \'\') { ?>
                                            <tr>
                                                <td colspan="2" class="img">
                                                    <img src="<?php echo $first_image;?>" alt="<?php the_title(); ?>" />
                                                </td>
                                            </tr>
                                            <?php } ?>
                                        </tbody>
                                    </table>
                                </a>
                            </article>
                        <?php endwhile; ?>                      
                        <?php else:  ?>
                          <p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
                        <?php endif; ?>
                    </div>
                    <nav class="page-navigation">
                    <?php
                    $big = 999999999; // need an unlikely integer
                     echo paginate_links( array(
                        \'base\' => str_replace( $big, \'%#%\', get_pagenum_link( $big ) ),
                        \'current\' => max( 1, get_query_var(\'paged\') ),
                        \'prev_text\'    => __(\'« Previous\'),
                        \'next_text\'    => __(\'Next »\'),
                        \'total\' => $the_query->max_num_pages
                    ) );
                    ?>
                    </nav>
                </div>
            </div>
<?php get_footer(); ?> 

1 个回复
SO网友:slwr

好的,我找到了一个我无法解释的解决方案:我必须更改设置>阅读>博客页面最多显示=1

结束

相关推荐

Pagination for event query

我正在使用Modern Tribe Events Calendar我的问题是分页。这是对WP\\U查询分页的错误方式,还是有其他方法可以对事件日历分页?我找到了一个tutorial 这使用了WPNavi插件,但我想使用核心wordpress函数。<?php $upcoming = new WP_Query(); $upcoming->query( array( \'post_type\'=> \'tribe_events\', \'eve