Next/Previous post
-
How do I change the next/previous post text (and maybe add the thumbnail of the next/previous post…), and possible its location? I created a child theme, but got a bit stuck 🙂
I am using HappenStance Premium Version: 1.1.3
Cheers,
Marc
-
Dear Marc,
please insert the following code into your child theme’s “functions.php”:
function happenstance_child_prev_next($nav_id) { ?> <?php $happenstance_previous_post = get_adjacent_post( false, "", true ); $happenstance_next_post = get_adjacent_post( false, "", false ); ?> <div id="<?php echo $nav_id; ?>" class="navigation" role="navigation"> <div class="nav-wrapper"> <?php if ( !empty($happenstance_previous_post) ) { ?> <p class="nav-previous"><a href="<?php echo esc_url(get_permalink($happenstance_previous_post->ID)); ?>" title="<?php echo esc_attr($happenstance_previous_post->post_title); ?>"><?php _e( '← Previous post', 'happenstance' ); ?></a></p> <?php } if ( !empty($happenstance_next_post) ) { ?> <p class="nav-next"><a href="<?php echo esc_url(get_permalink($happenstance_next_post->ID)); ?>" title="<?php echo esc_attr($happenstance_next_post->post_title); ?>"><?php _e( 'Next post →', 'happenstance' ); ?></a></p> <?php } ?> </div> </div> <?php }and edit the text strings
<?php _e( '← Previous post', 'happenstance' ); ?>and<?php _e( 'Next post →', 'happenstance' ); ?>according to your needs.Then edit the following code in your child theme’s “single.php”:
<?php happenstance_prev_next('happenstance-post-nav'); ?>in this way:
<?php happenstance_child_prev_next('happenstance-post-nav'); ?>Note: This support forum should be used only for questions related to the Free version of the HappenStance theme. Because the above described solution would work also in the Free version, I responded it here, but for another questions related to the Premium version please use the support forum on my website. Thank you!
Best regards,
Tomas TomanHi Tomas,
Many thanks for that! It works perfectly!
Cheers,
MarcPS: Sorry, I tried to go to your website, but it was ‘down for maintenance’; why I decided to post here, next time I’ll try to use your website.
Hi Marc,
yes, I understand. 🙂 Anyway, I am glad that I could help you!
Best regards,
Tomas TomanReally LOVE your theme(s)!!!
The topic ‘Next/Previous post’ is closed to new replies.
