我一直在使用带有数字分页的自定义查询(即<;1 2 3 4>)。我已经按照我预期的方式工作了,但是,它不断抛出以下错误:
注意:使用未定义的常量custom\\u分页-假定在/websitepath/wp-content/plugins/portgallery/galleryTemplate中使用“custom\\u分页”。php第129行
第129行是:if (function_exists(custom_pagination)) {
我不知道如何解决这个问题,在抄本或谷歌搜索时似乎也找不到太多帮助。我肯定我错过了一些愚蠢的事情。帮助
<?php
function custom_pagination($numpages = \'\', $pagerange = \'\', $paged = \'\') {
if (empty($pagerange)) {
$pagerange = 2;
}
global $paged;
if (empty($paged)) {
$paged = 1;
}
if ($numpages == \'\') {
global $wp_query;
$numpages = $wp_query->max_num_pages;
if (!$numpages) {
$numpages = 1;
}
}
$pagination_args = array(
\'base\' => get_pagenum_link(1) . \'%_%\',
\'format\' => \'page/%#%\',
\'total\' => $numpages,
\'current\' => $paged,
\'show_all\' => False,
\'end_size\' => 1,
\'mid_size\' => $pagerange,
\'prev_next\' => True,
\'prev_text\' => __(\'«\'),
\'next_text\' => __(\'»\'),
\'type\' => \'plain\',
\'add_args\' => false,
\'add_fragment\' => \'\'
);
$paginate_links = paginate_links($pagination_args);
if ($paginate_links) {
echo "<nav class=\'custom-pagination\'>";
echo "<span class=\'page-numbers page-num\'>Page " . $paged . " of " . $numpages . "</span> ";
echo $paginate_links;
echo "</nav>";
}
}
?>
<?php
$paged = ( get_query_var(\'page\') ) ? get_query_var(\'page\') : 1;
$query_args = array(
\'taxonomy\' => \'portfolio_categories\',
\'term\' => \'artwork\',
\'post_type\' => \'portfolio\',
\'posts_per_page\' => 4,
\'paged\' => $paged
);
$the_query = new WP_Query($query_args);
?>
<?php if ($the_query->have_posts()) : ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<article class="loop">
<h3><?php the_title(); ?></h3>
<div class="content">
<?php the_excerpt(); ?>
</div>
</article>
<?php endwhile; ?>
<?php
if (function_exists(custom_pagination)) {
custom_pagination($the_query->max_num_pages, "", $paged);
}
?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e(\'Sorry, no posts matched your criteria.\'); ?></p>
<?php endif; ?>