Smarter Navigation

Alert: This plugin is no longer under active development, because I left WordPress.

Smarter Navigation: Version 1.3

In previous versions, the plugin stored individual post ids in a cookie. To avoid having a huge cookie, I limited it to 500 ids. Needless to say, this was not a very scalable solution.

In the current version, it remembers the query vars instead, which are later used to get the adjacent posts.

In this way, the amount of data in the cookie stays the same, no matter how many posts you have.

Smarter Navigation: Version 1.2

Two template tags have been added:

If you have posts in multiple categories, you can use get_referrer_category() to retrieve the category object, based on the referrer url.

get_referrer_url() returns the full URL of the referrer.

Also, there are two extra arguments for previous_post_smart() and next_post_smart(): $in_same_cat and $excluded_categories.

This is how the function prototype looks like:

previous_post_smart(
	$format = '« %link',
	$title = '%title',
	$fallback = true,
	$in_same_cat = false,
	$excluded_categories = ''
);

Smarter Navigation: Version 1.1

Two important bugfixes:

  1. Works with sets of posts split on multiple pages (up to 500 posts).
  2. Works correctly if you open multiple tabs on the same site.

Smarter Navigation: Version 1.0

The default previous_post_link() and next_post_link() have an option to restrict adjacent posts to the current category. This plugin takes one step further:

If you visit an archive page (category, tag, date, author, search etc.) and then visit a single post from that page, the previous_post_smart() and next_post_smart() will point only to the other posts in that archive page.

This is particularly useful for photoblogs (that’s where I use it).

If there isn’t an adjacent post, it will use the normal template tags.