Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [previous-post-link]

Used on single posts, this template tag displays a link to the previous post which exists in chronological order from the current post. This tag must be used in The Loop.

1
vote
1answer
22 views

previous/next_post_link in the same sub-category?

As the title: is there a way to navigate between posts of the same subcategory using the previous_post_link and next_post_link functions? But maintaining however both the category and the sub-category ...
0
votes
0answers
13 views

next_post_link() and previous_post_link() in single-cpt.php file not working

I am trying to display links to previous post and next post in for a custom post type regardless of whatever custom taxonomies they are attached to. I have a custom post type called experiencecont ...
0
votes
1answer
25 views

Dynamic next and previous post links

Is there any way to change the next and previous post links dynamically. By default the previous post link takes to the previous post. However I want it to link to some different post, that I posted ...
0
votes
1answer
60 views

next_posts_link not visible on first page

I cannot get the <?php next_posts_link(); ?> working in my custom post loop on the first page ( website.com/news). The funny thing is that <?php previous_posts_link(); ?> does work on the ...
0
votes
0answers
46 views

get_next_post term exclusion not working as expected

I have posts in a custom post type with a custom taxonomy. I have 5 total posts, all of which are in term A. 2 of the 5 are in term B. I want to exclude term A from the next and previous post links. ...
0
votes
1answer
19 views

Back, Next, and Previous links for the REFERRING term archive

I have a bit of a tricky one. I can figure out how to do back, previous, and next links for a specific taxonomy term, what I can't figure out is how to specify which term the user started viewing ...
-1
votes
2answers
515 views

next_posts_link not working in custom loop

I've created a custom loop for posts, that works with Bootstrap, in which, I've added pagination - however it doesn't seem to be working. It just shows an empty button... <?php $args = array( ...
0
votes
1answer
28 views

Wordpress next/prev links Issue

previous_post_link(); next_post_link(); this code should display previous link and then next link , its showing totally opposite , is this wordpress issue or this is something me doing wrong
0
votes
0answers
148 views

get_previous_post_link and get_next_post_link of custom post type that share custom field value

I have a custom post type called chapter. I'm trying to show the next chapter with something like the get_next_post_link() and get_previous_post_link(). I get the next chapter that is posted, but I ...
0
votes
2answers
769 views

Can I use get_adjacent_post for specific categories?

I want to get next and previous posts based on a particular category slugs. For example, some posts might have the "sports" category while another has the "tech" category. I was hoping to plug in a ...
0
votes
1answer
305 views

Previous/Next custom post links within custom taxonomy

I have seen this issue in quite a few threads so apologies if I've replicated an issue here but I've had no joy in attempting to implement the solutions I have found. I have a custom post type: show, ...
2
votes
1answer
2k views

How can I get next post id after current post id for custom post type

Hello I am using WordPress custom post type. In this I need to get the post id of the next post which will be present in the custom post type. The issue I am facing is that this post id will be ...
0
votes
0answers
21 views

Url PrevPost after migration

I make a migration to another server with duplicator and I have a bug with the URL when I call this : <a href="<?php echo $prev_post->guid ?>"><?php echo $prev_post->post_title ...
0
votes
1answer
79 views

How to know if the most recent article

I would like to know how to know if the next article is the most recent ? And if is not the most recent, dont' show the content (The right arrow and "Article suivant") please, Here is my current code ...
0
votes
2answers
522 views

How to filter get previous post function by meta value DESC and post date DESC?

My loop displays featured posts and then posts in reverse chronological order. However when I use <?php echo get_previous_post(); ?> it grabs posts in reverse chronological order. How do I ...
1
vote
1answer
419 views

How to make my pagination loop continuously?

So I created some custom pagination for my single.php template to show next/previous posts at the bottom. However, the way it is working currently is linear(ie on the most recent post there is only a "...
0
votes
1answer
632 views

previous and next post of same category on singlepost.php

I want to show previous and next posts of same category in wordpress My code is : <?php $prev_post = get_previous_post(); $next_post = get_next_post(); ?> &...
0
votes
1answer
91 views

Wordpress post next/prev not working

I'm trying to add next/prev links to my wordpress post. This is the code for it: <div id="demo"> <?php $the_query = new WP_Query( array( 'category_name' => 'Case Study', '...
1
vote
0answers
52 views

Using 'previous_post_link()' & 'next_post_link()' on single attachment pages

I have uploaded a selection of audio files via the media uploader. I can successfully open an attachment page (single.php) for each file. However, the 'previous_post_link()' generates the current ...
0
votes
1answer
71 views

How do I modify the Previous and Next Page posts on blog pages to include “previous” and “next” before the links?

I want to add "previous" and"next" to the individual blogs since they only have the blog titles for the next and previous links. I want to keep the links and I am having a hard time using any of the ...
3
votes
2answers
289 views

Wordpress pagination link always leads to home page

I am making a pagination for this website by using a custom query and get_next_posts_link, get_previous_posts_link. The problem is that the link to older entries (get_next_posts_link) only works once, ...
0
votes
1answer
521 views

Get next post in same category not working WP 4.7.4

I have posts which assigned 1 of 2 different categories. On the single post view i want to show a next and previous link of posts with the SAME category. This should be straightforward, i've tried ...
2
votes
1answer
113 views

connect last post with first post

next/prev from my first to last and the other way around cant find a solution for that i am using this code for next <?php next_post_link('%link','<img src="img-location"/>'); ?> and ...
0
votes
0answers
250 views

Next / Previous post links with multiple taxonomies

I am using previous_post_link and next_post_link to navigate between posts in the same custom taxonomy. The problem I am having is that I need to navigate between posts that have the same two custom ...
1
vote
1answer
197 views

Previous_post and Next_post - Custom Post Type

I have a custom post type and using this function to add for posts, previous and next buttons. The problem is that within the custom post type, I have subcategories defined by a custom field ...
1
vote
2answers
96 views

Previous/next post links displaying wrong category than is desired

I want my single.php to display posts in the same category for the previous and next posts underneath the post. The problem is that each of my posts belongs to multiple categories, and they are ...
0
votes
1answer
40 views

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

At present I am using the below code to navigate between previous and next post. <?php global $wp_query; if (is_single()) { ?> <div class="prev-navigation"> <?php ...
0
votes
1answer
71 views

I need to customize wordpress “previous” “next” links

I am a hubspot developer mostly, and hubspot has tokens for previous post link and previous post title, and the same for the next post and the images for these posts. You can use these to create ...
0
votes
2answers
604 views

Displaying the author of next and previous posts in pagination?

I have set up links to the next/previous posts on my single.php template. Currently I am using <?php previous_post_link(); ?> and <?php next_post_link(); ?> which gives me the title of the ...
0
votes
1answer
106 views

altering %title

I'd like to transform the result from %title in functions like next_post_link(). More specificaly, I created a function called short_title($title, $after, $length). The idea is to return the title ...
4
votes
1answer
273 views

WordPress previous_post_link exclude posts with multiple categories

I have a single-news page in WordPress where I am looping over all the posts and conditionally updating the previous and next buttons to exclude certain categories based on the current post's category ...
1
vote
1answer
75 views

Next Posts Prev Posts for Standard post format only

I am using the following functions in my single.php file to display links to Previous and Next posts: get_next_post(); get_previous_post(); I store them in 2 variables: $next_post = get_next_post();...
0
votes
1answer
32 views

Navigate to external link if last page or post in a category

I'm working on a project that ties in an old legacy site with a replacement Wordpress site. Is there a way I can add a link to a the post navigation to an external link when a user reached the last ...
0
votes
1answer
164 views

How do I use the add_query_arg function in a template tag like previous_post_link?

I am trying to change the output of the previous_post_link and the next_post_link and basically add a query argument to them. The documentation just mentions that you can use the %link placeholder ...
3
votes
3answers
906 views

How can I limit the length of the previous/next posts in my Wordpress Theme?

I am using the following code to show next/previous posts in my wordpress theme. <?php previous_post_link('<span class="left">&larr; %link</span>'); next_post_link('<span class="...
0
votes
0answers
153 views

Conditionally (cpt) filter previous and next_post_link

I'm using the next_post_link and previous_post_link functions in two different scenarios, first in my single-cpt.php and second in my single posts. The name of my cpt is "members". Note, that I'm ...
-1
votes
1answer
43 views

Multiple loops using next_posts_link & previous_posts_link

I have more than one loop in the same page and they are working perfectly, but the problem comes up when I try to use next_posts_link & previous_posts_link for a specific div. Example: <div ...
1
vote
0answers
869 views

get_adjacent_post - in same term or category not working

I am building a Next and Previous Post navigation for my 'Single post' pages, inside a plugin. What I am trying to do is get the Prev/Next post within the same category of a Custom Post Type. So I ...
0
votes
1answer
59 views

Single: Prev and next Post in same order as main query, in all categories

I am using something like these arguments to order the archive loop, to order posts by a custom field. $args = array( 'category_name' => $filter_cat, 'posts_per_page' => -1, '...
0
votes
1answer
405 views

Get ID for previous/next image link

For grabbing previous or next image link on attachment page we can use this https://codex.wordpress.org/Function_Reference/previous_image_link How do we get ID for that attachment? Because I would ...
0
votes
0answers
2k views

Next/Previous Post Links in single-[custom-post-type].php file

I have a post type 'location' that is a listing for each branch of a multi-branch company. I want to add a Left and Right arrow on each individual location post that will allow the users to cycle ...
1
vote
1answer
1k views

Next/Previous Posts Links: Alphabetically and from Same Category

I'm exhaustively searching for a method to provide Next and Previous Post Links in a different way from which it usually appears in Single Post. By DEFAULT it: Is chronological ordered Links to ...
1
vote
2answers
786 views

get_next_post_link() and get_previous_post_link() return wrong posts

I'm using get_next_post_link() and get_previous_post_link() within the loop but the returned posts are not correct. get_next_post_link() shows the previous post and get_previous_post_link() gives the ...
0
votes
2answers
733 views

Modify previous and next post links to current Authors Other posts

I have created custom post type gallery. How change the previous post and next post link to point to the current Authors posts only? The Previous and Next Post link should not display if there are ...
2
votes
1answer
1k views

next_post_link and previous_post_link in custom post type single page, in same non-custom category

I have a custom post type "realisation", for which I've made a file single-realisation.php. These posts use the non-custom taxonomy "category". In this page, I use the next_post_link() and ...
0
votes
1answer
662 views

WordPress not showing pagination links

In my WordPress Index.html I am pulling out the 3 latest posts by using <?php query_posts('posts_per_page=3') ?> <?php while(have_posts()) : the_post(); ?> //rest of the post related ...
0
votes
1answer
192 views

Tweak next_post_link for it to include thumbnail

I am using a fork from underscores.io, and there is this code: next_post_link( '<div class="nav-next">%link</div>', _x( '%title <span class="meta-nav">&rarr;</span>...
1
vote
1answer
522 views

previous next with custom-post-type by order attribute

I have a custom-post-type called 'artists'. I list them by the order attribute (menu_order). $args = array( 'post_status' => 'publish', 'post_type' => array('artists), 'orderby'=&...
0
votes
2answers
1k views

Pagination for custom loop on custom page template is not displaying anything

I have created a page where user can see his favourite post which has been bookmarked by him get_user_favorites($user_id); This function is responsible for returning me all the favourite posts ...
4
votes
1answer
1k views

How can I get next/ previous post links to order by a filter (by the last word of the title)?

I am trying to use the next/ previous post link functions by Wordpress to move between posts of a custom type based on the surname of a person. The custom type represents a person with a post title ...