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 implement next/prev within category archive?

It sends you to the next/prev post by date of been published. I don’t know what gives you these next/prev links and where (single.php, category.php, archive.php or any other custom template file). Without knowing more (some code example) all that I can give to you is this: $page_nr=”&paged=”; $page_nr = get_query_var( ‘paged’ ) ? $page_nr.get_query_var( … Read more

Retrieving next_post_link() and previous_post_link() in functions.php

<?php function get_all_images($post_id=0, $size=”poster”, $attributes=””) { global $post; setup_postdata($post); $post_id = $_POST[‘post_id’]; if ($post_id<1) $postid = get_the_ID(); $post = get_post($post_id); $get_content = $post -> post_content; $content = apply_filters(‘the_content’, $get_content); $content = str_replace(‘]]>’, ‘]]&gt;’, $content); $title = get_the_title($post); $previous_post = get_previous_post(); $next_post = get_next_post(); $previous_link_url = get_permalink(get_previous_post(false,”,true)); $next_link_url = get_permalink(get_next_post(false,”,false)); if (!empty( $previous_post )) $previous_link = … Read more

pagination/prev and next page links not showing

OK, it seems that we have two errors here: You should use posts_nav_link() instead of previous_post_link() and next_post_link(). The functions you used point to previous/next posts, not pages. You can refer to the WordPress Codex for more information. You should place posts_nav_link() after endwhile so that it is not repeated for every single post excerpt … Read more