• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Post pagination showing random posts (or no posts)

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Post pagination showing random posts (or no posts)

This topic is: not resolved

Tagged: featured images, post navigation

  • This topic has 7 replies, 2 voices, and was last updated 7 years, 3 months ago by Christina.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • February 8, 2018 at 3:17 pm #216355
    Christina
    Participant

    My post navigation is showing either random posts, no posts at all, or showing one post and then linking to another. Could anyone tell me what the problem might be? Here's my function:

    function prev_next_post_nav() {
    	if( !is_singular('post') ) 
    		return;
    
    		if( $prev_post = get_previous_post() ): 
    			echo'<span class="prev-next-navigation previous">';
    			$prevpost = get_the_post_thumbnail( $prev_post->ID, 'thumbnail-portrait', array('class' => '.pagination-previous')); 
    			previous_post_link( '%link',"$prevpost  <p>Previous</p>", TRUE ); 
    			echo'</span>';
    		endif; 
    	
    		if( $next_post = get_next_post() ): 
    			echo'<span class="prev-next-navigation next">';
    			$nextpost = get_the_post_thumbnail( $next_post->ID, 'thumbnail-portrait', array('class' => '.pagination-next')); 
    			next_post_link( '%link',"$nextpost  <p>Next</p>", TRUE ); 
    			echo'</span>';
    		endif; 
    } 
    http://foolproofliving.com
    February 9, 2018 at 2:51 am #216368
    Brad Dalton
    Participant

    Which hook are you using?


    Tutorials for StudioPress Themes.

    February 9, 2018 at 9:10 am #216373
    Christina
    Participant

    I moved it from entry content to after entry. Is that the problem?

    February 9, 2018 at 9:51 am #216374
    Christina
    Participant

    I moved it to the entry footer, but it's still not working properly.
    add_action( 'genesis_entry_footer', 'prev_next_post_nav' );

    February 9, 2018 at 9:54 am #216375
    Brad Dalton
    Participant

    I don't think so. When i test the code it works.


    Tutorials for StudioPress Themes.

    February 9, 2018 at 10:54 am #216378
    Christina
    Participant

    Hmm, any ideas of where I could start looking for the cause of the problem on the live site? I don't even know where to start.

    On the latest posts, it just shows a blank spot for the previous post. It works on some posts, but on others it will show a post that was 3 or 4 posts previous, not immediately previous (same for "next" posts).

    And thank you very much for your help so far!

    February 9, 2018 at 11:18 am #216379
    Brad Dalton
    Participant

    When i test the code it shows a previous post after the latest post. You might want to test the code in a fresh copy of the Genesis Sample theme to find out if its a problem with your theme.


    Tutorials for StudioPress Themes.

    February 9, 2018 at 3:55 pm #216385
    Christina
    Participant

    Yeah, it's a problem with the theme. I've replicated it on a staging site, but even after stripping almost all other code in the child theme, it's still happening. I'll keep looking. Thanks for verifying that the code is good Brad!

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble