Support » Theme: Fukasawa » Display next/previous post title on single posts

  • Resolved antoniomc76

    (@antoniomc76)


    Hi there!
    I’d like to display the title of the next/previous post at the bottom of singles posts.
    By default, my theme (Fukasawa) just displays this kind of links:

    <– Previous post | Next post –>

    I’d prefer something like this:

    <– Previous post | Next post –>
    Title of the post | Title of the post

    I’ve tried to add this piece of code on single.php:
    <?php previous_post_link(); ?> <?php next_post_link(); ?>

    With no success.
    Any idea?
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello Antoniomc76,
    Here is the code In am currently using on my website (under Fukasawa). You will probably want to customise it for your site, but this should get you started :
    Christophe

    <?php
    $prev_post = get_previous_post();
    $next_post = get_next_post();
    ?>
    			
    <div class="post-navigation">
    			
    <?php
    	if (!empty( $prev_post )): ?>
    		<a class="post-nav-prev" title="<?php _e('Previous post', 'fukasawa'); echo ': ' . esc_attr( get_the_title($prev_post) ); ?>" href="<?php echo get_permalink( $prev_post->ID ); ?>">
    		<p>&larr; <?php _e('Previous post', 'fukasawa'); ?> <br> <?php echo esc_attr( get_the_title($prev_post) ); ?> </p>
    		</a>
    
    	<?php endif; ?>
    				 
    <?php
    	if (!empty( $next_post )): ?>
    		<a class="post-nav-next" title="<?php _e('Next post', 'fukasawa'); echo ': ' . esc_attr( get_the_title($next_post) ); ?>" href="<?php echo get_permalink( $next_post->ID ); ?>">
    		<p><?php _e('Next post', 'fukasawa'); ?> &rarr; <br> <?php echo esc_attr( get_the_title($next_post) ); ?> </p>
    		</a>
    	<?php endif; ?>
    				
    <div class="clear"></div>
    
    </div> <!-- /post-navigation -->
    • This reply was modified 2 years, 10 months ago by  chris1030. Reason: typo

    Thanks a lot chris1030, it works like a charm 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display next/previous post title on single posts’ is closed to new replies.