Link to previous/next entry using custom sorting order

The weblog:entries tag enables you to link to next/previous entry based on entry creation date.
But what if you want to use sorting order based on other parameter, and still have next/prev links?
Here’s the add-on that will help you!

Using Entry Linking plugin, you can sort your weblog entries based on any - standard or custom - field you want and make your next/prev links follow that order!

Example usage:

{exp:entry_linking entry_id="1" link="next" weblog="my_weblog"
 
orderby="my_custom_field" sort="ASC" status="open"
 
category="1|2"
 
mode="short"}
<a href="{path=site/{link_url_title}}">{link_title}</a>
{/exp:entry_linking} 

entry_id is the required parameter.
Possible values for link are ‘next’ and ‘prev’. Defaults to ‘next’.
You can use your custom field names for orderby parameter (defaults to entry_date).
All returned variables will be prefixed with ‘link_’

You can use the plugin in any part of your template.

The current version of plugin supports only ‘short’ mode (i.e. return only entry_id, title and url_title). I don’t think you need more for pagination smile But if you do - please let me know and I’ll include ‘full’ mode in future releases.

save Download entry_linking plugin - NEW v.1.2

Thanks! I was just looking for something like this, but couldn’t find anything even remotely useful. Works just great and is flexible enough!

One suggestion though: maybe the first/last links could be hidden if viewing the first/last entry? Now the links are looping the whole weblog. Just an idea smile

Jani, you can achieve this by replacing

if ($link=='next')
    
{
      $pos
++;
      if (
$pos==count($ids)) $pos=0;
    
else {
      $pos
--;
      if (
$pos==-1$pos=count($ids)-1;
    

with

if ($link=='next')
    
{
      $pos
++;
      if (
$pos==count($ids)) return $TMPL->no_results;
    
else {
      $pos
--;
      if (
$pos==-1)  return $TMPL->no_results;
    

great plugin, thank you.

It would be awesome if you could limit the next and prev links to a specific category as well.

Would that be difficult to accomplish?

James, that sounds like a good feature. I think I’ll code that and release in a week or two.

I second the request to limit to specific categories. That would be awesome.

Nice plugin. Thanks.
Can you let me know when it’s been updated to ‘limit to specific categories”. That would be perfect for a project I’m working on smile

The ‘limit to specific categories’ feature has been implemented. Use it by passing parameter catagory=“1”. You can specify multiple categories by separating them with a pipe.

Please note that I did not test myself this yet smile so if you encounter any bugs, report them here.
The donwload link is in the post above.

Hey,
Thanks for the update.
Have given it a go but I can’t get it to limit to the category I’m on. The ‘category’ tag doesn’t seem to have any effect. Has any one else had any issues?

Cheers

Steve, do you use ‘category’ tag or parameter? You should use parameter (like in example in docs).
If you are willing, I can have a look at your installation and quickly fix everything.

Soon after - bugfix version (1.2). Please download and install this one.

Great plugin!

I second the request to be able to turn off the looping between the last-to-first and first-to-
last of the results.

Could you provide any quick fixes to this?

Eek, I just noticed that you had followed up already on this topic. I was thrown off by the order of the comments.

The fix you posted worked really great! Thanks again for an awesome plugin.

You’re welcome, Mason smile

Very useful article.Surely will visit your blog again later,thanks for sharing.

Name:

Email:

Remember my personal information

Notify me of follow-up comments?

Submit the word you see below: