【如何修复自定义wordpress项目组合分页】如何修复自定义wordpress项目组合分页?下面是我的代码, 可以正常工作, 但分页不会到来。我可以通过WP PageNavi这样的插件来实现吗?
以下是我的自定义模板名称:Portfolio
<
?php
/*
Template Name: Portifolio
*/
?>
<
?php
get_header();
?>
<
div class="single-full-width-container single-page-header-container">
<
header class="container">
<
?php
the_title('<
h1 class="single-page-heading">
', '<
/h1>
');
?>
<
ul class="single-page-breadcrumbs">
<
?phpif (function_exists('bcn_display') &
&
!is_front_page())
{
bcn_display();
}?>
<
/ul>
<
/header>
<
/div>
<
div class="container">
<
div class="row">
<
main role="main" class="isotope-portfolio portfolio-wrapper four-cols-portfolio span12">
<
div class="row">
<
?php
$terms = get_terms("tagportifolio");
$count = count($terms);
echo '<
ul id="isotope-filters" class="pagination-centered unstyled">
';
echo '<
li>
<
a href="http://www.srcmini.com/#all" data-filter="*">
Show All<
/a>
<
/li>
';
if ($count >
0)
{
foreach($terms as $term)
{
$termname = strtolower($term->
name);
$termname = str_replace(' ', '-', $termname);
echo '<
li>
<
a href="http://www.srcmini.com/#' . $termname . '" data-filter=".' . $termname . '" rel="' . $termname . '">
' . $term->
name . '<
/a>
<
/li>
';
}
}echo "<
/ul>
";
?>
<
div id="container">
<
?php
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$loop = new WP_Query(array(
'post_type' =>
'project', 'posts_per_page' =>
5, 'paged' =>
$paged
));
$count = 0;
?>
<
?phpif ($loop):
while ($loop->
have_posts()):
$loop->
the_post();
?>
<
?php
$terms = get_the_terms($post->
ID, 'tagportifolio');
if ($terms &
&
!is_wp_error($terms)):
$links = array();
foreach($terms as $term)
{
$links[] = $term->
name;
}$links = str_replace(' ', '-', $links);
$tax = join(" ", $links);
else:
$tax = '';
endif;
?>
<
article class="portfolio-article item <
?php
echo strtolower($tax);
?>
span4">
<
?php
$infos = get_post_custom_values('_url');
?>
<
div class="portfolio-content article-content">
<
?php
if (has_post_thumbnail())
{
$large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id() , 'large');
echo '<
a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" rel="lightbox" class="portfolio-teaser-pic fancybox">
';
the_post_thumbnail(array(
370, 370
));
echo '<
/a>
';
}?>
<
div class="meta-info">
<
span class="meta-info-buttons likes-no">
<
?php
echo $term->
name;
?>
<
/span>
<
span class="meta-info-buttons comments-no">
<
a href="http://www.srcmini.com/<
?php
echo $infos[0];
?>">
Live Preview<
/a>
<
/span>
<
span class="meta-info-buttons more-details">
<
a href="http://www.srcmini.com/<
?php
the_permalink() ?>">
More Details<
/a>
<
/span>
<
/div>
<
div class="portfolio-content-wrap">
<
h1 class="portfolio-heading article-heading">
<
a href="http://www.srcmini.com/<
?php
the_permalink() ?>">
<
?php
the_title();
?>
<
/a>
<
/h1>
<
p>
<
?php
echo get_the_excerpt();
?>
<
/p>
<
/div>
<
/div>
<
/article>
<
?php
endwhile;
else: ?>
<
p>
Sorry, no portfolio entries for while.<
/p>
<
?php
endif;
?>
<
?php
wp_reset_query();
?>
<
/div>
<
?phpif (function_exists('wp_pagenavi'))
{
wp_pagenavi();
wp_reset_postdata();
// avoid errors further down the page
}?>
<
/div>
<
/main>
<
/div>
<
/div>
<
?php
get_footer();
?>
#1你需要使用以下
echo paginate_links( array(
'base' =>
str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' =>
'?paged=%#%', 'current' =>
max( 1, get_query_var('paged') ), 'total' =>
$loop->
max_num_pages, 'next_text'=>
__('Next ?'), ) );
这是在Wordpress中如何实现此示例。
推荐阅读
- 如何找到短代码[WordPress]文件的位置
- 如何在WordPress中以自定义主题显示页面内容()
- Unity HoloLens2 开发笔记:环境配置
- 谁说count(*) 性能最差,我需要跟你聊聊
- java集合13——— Stack源码分析走一波
- Flutter 专题51 图解动画小插曲之 Flare 动画 #yyds干货盘点#
- Laravel基于RT模式实现分布式事务(全球首创支持子服务嵌套事务)
- 京东移动端组件库 React 版如约而来
- 3.FastAPI参数