Need next and previous post arrows using Integrity w/Pro

Hi, apologies as I know this has been asked before. I have tried a couple of the functions.php additions combined with the CSS from previous replies but no luck. I’m obviously just looking for next and previous arrows at the bottom of each blog post, or even just text saying ‘Previous Post’ etc.

I’m using Pro with the Integrity stack. The other replies I found seemed to pertain to X, so perhaps there is a difference there?

Thanks,
Shaun

Hello Shaun,

In Integrity stack, next and previous post function are already available. It is part of the breadcrumb. Since breadcrumb is part of the legacy header, it is missing for Pro. As an alternative, please check this thread as guide on adding it after single post content. Hope this helps.

Hi there, thanks for your reply.

I added the custom code from that thread to my child theme’s functions.php file, but I’m still not getting the ‘previous’ & ‘next’ arrows. I know the issue is connected to having breadcrumbs turned on but I don’t want that - is there a workaround at all?

Thanks!

Hi @ShaunCoward,

Perhaps it’s not a custom function that you’re looking for but the Dynamic Content feature. Try this, please create a Global Block with only two buttons on the content, name the buttons previous and next

It looks like the screenshot below, you can style your button later.

On the Previous button URL add this {{dc:post:permalink post="prev"}} and this for the Next button {{dc:post:permalink post="next"}} URL.

Save that Global Block and get the shortcode, use the solution provided here for adding that Global Block to every posts. If it works, then fill free to style your Global Block, whether you want text or arrows or both on your Buttons.

Cheers!

Okay, I’ll give that a try - thanks!

Argh! Didn’t work either, but I am guessing because the part that says custom_post_slider in the solution provided needs to be called something else. Any ideas?

Thanks once again!

Hello Shaun,

Your code with a global block should be like this:

function custom_post_arrows() {
		if ( is_single() ) {
  			echo do_shortcode('[cs_gb id=123]');
		}
}
add_action('x_before_the_content_end', 'custom_post_arrows');

Or if you follow the code provided by Christian that should work too.

add_action( 'the_content', 'add_next_post_item_link' );

function add_next_post_item_link ( $content ) {
    if ( is_singular('post') ) {
	    $next_name = 'Next Post <i class="x-icon x-icon-chevron-right" data-x-icon="&#xf054;"></i>';
	    $prev_name = '<i class="x-icon x-icon-chevron-left" data-x-icon="&#xf053;"></i> Previous Post';
	    $next_link = get_next_post() ? '<a style="float: left;" href="' . get_permalink( get_next_post()->ID ) . '">' . $prev_name . '</a>' : '';
	    $prev_link = get_previous_post() ? '<a style="float: right;" href="' . get_permalink( get_previous_post()->ID ) . '">' . $next_name . '</a>' : '';
	    $posts = '<div class="wp-post-navigation-next">'.$next_link.$prev_link.'</div>';
	    return $content . $posts;
    } else {
	    return $content;
    }
}

Please let us know how it goes.

Success! And I think it would have worked a long time ago if I hadn’t managed to make it hard for myself. For anyone else looking at this, here’s what happened.

Basically I was uploading the code via ftp to my child theme’s function.php file, but nothing was happening. Double checked everything, couldn’t figure it out. Then I looked at the functions.php file from the WordPress editor in the dashboard and guess what - no code. So I then added the code directly via my cPanel and it worked. I can only guess that the problem was related to me having renamed my child theme. But to confirm, I used the Global Block method with the shorter code to go in my functions.php file, and it definitely works.

Thanks all, appreciate the help!

Hi Shaun,

Thanks for letting us know. Perhaps there is an issue with your FTP connection or the File Permission that is why the changes were not not saving.

Glad to hear the issue is sorted. Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.