Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #890114
    thetastesf
    Participant

    Can you tell me how to set up/add a previous post button at the end of my posts? thetastesf.com

    #890116
    thetastesf
    Participant
    This reply has been marked as private.
    #890499
    Prasant Rai
    Moderator

    Hello There,

    Thanks for writing in!

    Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released.

    Kindly use following code in your child theme’s functions.php file:

    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-chevron-right\"></i>";
    		$prev_name = "<i class=\"x-icon-chevron-left\"></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;
    	}
    }

    Let us know how it goes.

    Thanks.

  • <script> jQuery(function($){ $("#no-reply-890114 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>