1

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

2 Answers 2

0

This 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()?.)

2
  • Thanks, I will take a look at that link. The way I was doing it was compatible with 3.4 but not with 3.5. I verified that the link disappeared immediately after upgrade (I didn't upgrade with other plugins that may have caused the change either).
    – Adam
    Dec 17, 2012 at 21:37
  • I streamline & modified the code to fit that logic (I think?) but still no luck on getting navigation links to show up: pastebin.com/vMxRN4tx
    – Adam
    Dec 18, 2012 at 0:46
0

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 : ?>
1
  • Hi - if your answer worked then please consider accepting it to help keep the site tidy. Aug 5, 2016 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.