• 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

How to edit next and previous post links (PHP problems)

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 › How to edit next and previous post links (PHP problems)

This topic is: resolved

Tagged: Magazine Pro, next post, pagination

  • This topic has 3 replies, 3 voices, and was last updated 12 years, 7 months ago by samw.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • March 9, 2014 at 10:34 pm #94118
    cookieandkate
    Member

    Hi,

    I've searched all over the place and tried every code snippet I can find. I just want to edit my previous and next post links (which currently display the post titles) by adding "older post" and "newer post" labels above those titles.

    I've managed to add a whole new set of previous and next post links with the following code, but I just want one set (the original set) to display.

    `
    //* Add post navigation (requires HTML5 theme support)
    add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' );

    //* Customize the next and previous links
    add_action('genesis_after_entry', 'next_previous_after_posts', 5);
    function next_previous_after_posts() {
    if ( is_single() ) {
    ?>
    <div class="adjacent-entry-pagination pagination">
    <div class="pagination-previous alignleft">
    <?php previous_post('<div class="custom">&larrtl; newer post</div> %', '', 'yes'); ?>
    </div><div class="pagination-next alignright">
    <?php next_post('<div class="custom">older post &rarrtl;</div> %', '', 'yes'); ?>
    </div></div>
    <?php
    } }'

    I've tried deleting the "add_action('genesis_after_entry'," line and changing next_previous_after_posts to genesis_prev_next_post_nav, but it kills my site. I'm clearly missing something.

    If you can help me with this issue, I would so appreciate it.

    Thank you,
    Kate

    March 10, 2014 at 6:57 am #94154
    efuller
    Member

    Kate:

    Please try replacing your code with the code below:

    //* Add post navigation (requires HTML5 theme support)
    remove_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' );
    add_action( 'genesis_entry_footer', 'cookie_prev_next_post_nav' );
    
    function cookie_prev_next_post_nav() {
    	if ( ! is_singular( 'post' ) )
    		return;
    
    	genesis_markup( array(
    		'html5'   => '<div %s>',
    		'xhtml'   => '<div class="navigation">',
    		'context' => 'adjacent-entry-pagination',
    	) );
    
    	echo '<div class="pagination-previous alignleft">';
    	previous_post_link('%link', 'Older Post');
    	echo '</div>';
    
    	echo '<div class="pagination-next alignright">';
    	next_post_link('%link', 'Newer Post');
    	echo '</div>';
    
    	echo '</div>';
    }

    You should be able to replace the 'Older/Newer Post' text with anything you would like.

    Thanks,

    Eric


    I am a web developer

    March 10, 2014 at 9:14 am #94162
    cookieandkate
    Member

    THANK YOU! Thank you so much. Your code worked great. I modified it slightly to return the post titles instead of "Older Post"/"Newer Post" labels. I also switched the previous_post_link and next_post_link so the older posts link (on the posts) is on the same side as my older pages link (on the pages). I also added divs.

    Final result: http://i.imgur.com/VfHXRPh.png

    Final code: `//* Add post navigation (requires HTML5 theme support)
    remove_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' );
    add_action( 'genesis_entry_footer', 'cookie_prev_next_post_nav' );

    function cookie_prev_next_post_nav() {
    if ( ! is_singular( 'post' ) )
    return;

    genesis_markup( array(
    'html5' => '<div %s>',
    'xhtml' => '<div class="navigation">',
    'context' => 'adjacent-entry-pagination',
    ) );

    echo '<div class="pagination-previous alignleft">';
    next_post_link('%link', '<div class="custom">&larrtl; newer post</div> %title');
    echo '</div>';

    echo '<div class="pagination-next alignright">';
    previous_post_link('%link', '<div class="custom">older post &rarrtl;</div> %title');
    echo '</div>';

    echo '</div>';
    }
    '

    Thanks again!
    Kate

    March 20, 2014 at 12:43 am #95764
    samw
    Member

    Hi

    Wonder if you can help, tired to follow both your codes to add next and previous post links to Eleven Twenty Pro that display post titles..I cant seem to get this to work..

    Also, is there a way in Genesis to get the post title to display as a permalink. Many Thanks

    (Topic opened as below)
    Hi

    I am trying to edit the post navigation links in Eleven Twenty Pro to display the post title.

    Where is the place to edit this – cant find anything in functions.php or do I need to add a new function?

    Tried adding this to functions.php to test if its the right code but as no changes appeared in the link text, i guess not?

    //* Add post navigation (requires HTML5 theme support)
    remove_action( ‘genesis_entry_footer’, ‘genesis_prev_next_post_nav’ );
    add_action( ‘genesis_entry_footer’, ‘cookie_prev_next_post_nav’ );

    function cookie_prev_next_post_nav() {
    if ( ! is_singular( ‘post’ ) )
    return;

    genesis_markup( array(
    ‘html5′ => ‘<div %s>’,
    ‘xhtml’ => ‘<div class=”navigation”>’,
    ‘context’ => ‘adjacent-entry-pagination’,
    ) );

    echo ‘<div class=”pagination-previous alignleft”>’;
    previous_post_link(‘%link’, ‘new text1′);
    echo ‘</div>’;

    echo ‘<div class=”pagination-next alignright”>’;
    next_post_link(‘%link’, ‘new test 2′);
    echo ‘</div>’;

    echo ‘</div>’;
    }


    SEO & Online Marketing Consultant

    Metta3 | G+ | LinkedIn

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 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

© 2026 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