How to add thumbnail support to WordPress next / previous post loop?

Wherever you want to place your image: <?php get_the_post_thumbnail( get_previous_post(), [ 150, 150 ] ) ; ?> <?php get_the_post_thumbnail( get_next_post(), [ 150, 150 ] ) ; ?> You can replace the sizes [ 150, 150 ] with the ‘thumbnail’. Edit: The code that works for me: $next_post = get_next_post(); $previous_post = get_previous_post(); the_post_navigation( array( ‘prev_text’ … Read more

Next/previous post link to posts only within one or more specific categories

I solved it by abandoning the code and registering a new taxonomy. I then used this code in single.php: <?php if (has_term(‘[TERM-NAME]’, ‘[TAXONOMY-NAME]’)) : ?> <div class = “next-post”><?php next_post_link(‘%link &raquo;’, ‘%title’, true, ”, ‘[TAXONOMY-NAME]’) ?></div> <div class = “prev-post”><?php previous_post_link(‘&laquo; %link’, ‘%title’, true, ”, ‘[TAXONOMY-NAME’) ?></div> <?php endif; ?> Doing it like this allows … Read more

how to add previous and next link for the posts?

Here’s a good place to start: http://codex.wordpress.org/Template_Tags/previous_post_link http://codex.wordpress.org/Template_Tags/next_post_link As you will see, keeping the links to posts of the same category is as simple as setting an argument in the function. I would give an example but there are really good examples on the pages linked above.

Single post navigation Previous post link shows up but Next post link doesn’t

Ok this issue was very hard to get fixed. I finally found the solution: Above <?php if (have_posts()) : ?>: insert: <?php $max_entries_per_page = 0; $current_page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 0; query_posts(“category_name=mobiliario&showposts=1&paged=” . $current_page) ?> Bellow <?php endwhile; ?>: insert: <div class=”pagination”> <div class=”pagnext”><?php next_posts_link(‘—›’, $max_entries_per_page) ?></div> <div class=”pagprev”><?php previous_posts_link(‘‹—’, $max_entries_per_page) ?></div> </div> I … Read more

Next and Prev post link breaks code on last post

This should work. Wasn’t closed well <div id=”cooler-nav” class=”navigation”> <div class=”wpb_wrapper”> <h3>More Underwater Media</h3> </div> <?php $prevPost = get_previous_post(true); if($prevPost) {?> <div class=”nav-box previous”> <div class=”navig_thumb_wrapper”> <?php $prevthumbnail = get_the_post_thumbnail($prevPost->ID, array(100,100) );?> <?php previous_post_link(‘%link’,”$prevthumbnail”, TRUE); ?> </div> <?php previous_post_link(‘%link’,”<p>< %title</p>”, TRUE); ?> </div> <?php } ?> <?php $nextPost = get_next_post(true); if($nextPost) {?> <div class=”nav-box next” … Read more

How to Navigate within Category? Lot of codes here on stackexchange didn’t work

Both previous_post_link and next_post_link accept a 3rd boolean parameter $in_same_term, which specifies whether link should be in a same taxonomy term. So in your scenario you would be looking to make the following update: previous_post_link <?php previous_post_link(‘%link’, ‘&Lang; &Lang; &Lang; %title’) ?> updated to <?php previous_post_link(‘%link’, ‘&Lang; &Lang; &Lang; %title’, true) ?> and next_post_link <?php … Read more

make random internal linking in the middle of posting

You can create a shortcode which can be used anywhere inside a post. The shortcode would be responsible for fetching a random post and displaying it. Example code: <?php /* * Plugin Name: Random Post * Description: Display random post * Version: 1.0 * Author: windyjonas * Author URI: https://www.jonasnordstrom.se */ function display_random_post() { ob_start(); … Read more