admin管理员组文章数量:1129424
After upgrading to 3.5, I discovered that navigation has disappeared outside of the main index page. Theme is TwentyEleven and I've verified that this still occurs after disabling all plugins.
<?php if ( $wp_query->have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php /* Start the Loop */ ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<?php get_template_part( 'content-beers', get_post_format() ); ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<?php twentyeleven_content_nav( 'nav-below' ); ?>
Live site page
After upgrading to 3.5, I discovered that navigation has disappeared outside of the main index page. Theme is TwentyEleven and I've verified that this still occurs after disabling all plugins.
<?php if ( $wp_query->have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php /* Start the Loop */ ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<?php get_template_part( 'content-beers', get_post_format() ); ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<?php twentyeleven_content_nav( 'nav-below' ); ?>
Live site page
Share Improve this question edited Feb 23, 2015 at 4:15 Pieter Goosen 55.4k23 gold badges115 silver badges209 bronze badges asked Dec 17, 2012 at 19:46 AdamAdam 4771 gold badge8 silver badges19 bronze badges2 Answers
Reset to default 0This code didn't change since Twenty Eleven's initial release. Navigation is only printed if your query has more than one page. Could that be it?
Since you are calling $wp_query->have_posts()
rather than have_posts()
, this suggests you are modifying or overriding the query, which may be confusing WordPress (and it's not WP's fault). (See When should you use WP_Query vs query_posts() vs get_posts()?.)
Winning code (had someone help & it looks like they more or less copy-pasted from the front page. Not sure why I had arranged it differently on the beers page to begin with...
<?php query_posts('post_type=beer&paged='.get_query_var('paged') ); ?>
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php if ( 'beer' == get_post_type() ) {
get_template_part( 'content-beers', get_post_format() );
} else;
?>
<?php endwhile; ?>
<?php twentyeleven_content_nav( 'nav-below' ); ?>
<?php else : ?>
本文标签: wp querytwentyelevencontentnav hook no longer outputs navigation link after 35 upgrade
版权声明:本文标题:wp query - twentyeleven_content_nav hook no longer outputs navigation link after 3.5 upgrade 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736740523a1950486.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论