我读过很多关于同一问题的帖子,但似乎没有一篇对我有用。
我在索引中查询了一个自定义帖子。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(); ?>