Next/Previous Post Link Plus for WordPress

I do not request donations for my plugins, but if you find this plugin helpful, please visit the WordPress.org plugin directory and give it a 5-star rating. Thanks!

Summary

Upgrades the next/previous post link functions to reorder or loop adjacent post navigation links, sort on custom fields, return multiple links, display post thumbnails, and customize the link format.

IMPORTANT: Make sure you are using the right plugin.

The two plugins have similar sounding, but different, function names. If you mistakenly install the wrong plugin, you will get a “call to undefined function” error.

IMPORTANT: This plugin is not compatible with PHP 4. If you try to install it on a host running PHP 4, you will get a parse error. WordPress has officially ended support for PHP 4 as of version 3.2, so you should upgrade to PHP 5.2 now. For those who cannot upgrade to PHP 5 at this time, you can download the alternate PHP 4 compatible version of the plugin here. The only difference with the PHP 4 version is that the %category variable will not work with custom taxonomies.

Description

This plugin creates two new template tagsnext_post_link_plus and previous_post_link_plus — which are upgraded versions of the core WordPress next_post_link and previous_post_link template tags. The new tags include all of the functionality of the core tags, plus the following additional options:

  • Sort next/previous post links on columns other than post_date (e.g. alphabetically).
  • Sort next/previous links on custom fields (both string and integer sorts are supported).
  • Full WordPress 3.3 compatibility, including support for custom post types, custom taxonomies, and post formats.
  • Loop around to the first post if there is no next post (and vice versa).
  • Retrieve the first/last post, rather than the previous/next post (for First|Previous|Next|Last navigation links).
  • Display post thumbnails alongside the links (WordPress 2.9 or higher).
  • Truncate the link titles to any length, and display custom text in the tooltip.
  • Display the title, date, author, category, and meta value of the next/previous links.
  • Specify a custom date format for the %date variable.
  • Restrict next/previous links to same category, taxonomy, format, author, custom field value, custom post ID list, or custom category list.
  • Exclude categories, custom taxonomies, post formats, or individual post IDs.
  • Three category exclusion methods for greater control over the navigation stream.
  • Return multiple next/previous links (e.g. the next N links, in an HTML list).
  • Return the ID, title, date, href attribute, or post object of the next/previous links, instead of echoing them to the screen.
  • Return false if no next/previous link is found, so themes may conditionally display alternate text.
  • Works with Post Types Order and other popular post reordering plugins.

Parameters must be passed either as an array definition (recommended):

<?php next_post_link_plus( array(
'order_by' => 'post_date',
'order_2nd' => 'post_date',
'meta_key' => '',
'post_type' => '',
'loop' => false,
'end_post' => false,
'thumb' => false,
'max_length' => 0,
'format' => '%link &raquo;',
'link' => '%title',
'date_format' => '',
'tooltip' => '%title',
'in_same_cat' => false,
'in_same_tax' => false,
'in_same_format' => false,
'in_same_author' => false,
'in_same_meta' => false,
'ex_cats' => '',
'ex_cats_method' => 'weak',
'in_cats' => '',
'ex_posts' => '',
'in_posts' => '',
'before' => '',
'after' => '',
'num_results' => 1,
'return' => ''
) ); ?>

Or as a URL query style string (the ‘format’ and ‘link’ parameters cannot be specified using a query string, and true and false must be specified as ’1′ and ’0′):

<?php next_post_link_plus('order_by=post_date&meta_key=&loop=0&thumb=0&max_length=0&in_same_cat=1&excats=&num_results=1&echo=1'); ?>

The above parameters show the default usage. Note that you need only specify a parameter when you want to override the defaults.

Parameters

order_by

Specifies the primary column that should be used to sort the next/previous post links. If you are using either the query_posts function, or a post reordering plugin like Post Types Order to display your posts in any order other than reverse chronological, then you will want your next/previous post links to cycle through the posts in the same order. For example, to move through the posts in alphabetical order:

<?php next_post_link_plus( array('order_by' => 'post_title') ); ?>

The following are valid values: post_date, post_title, post_excerpt, post_name, post_modified, ID, post_author, post_parent, menu_order, comment_count, custom, numeric.

Default is post_date, unless the Post Types Order plugin is installed, in which case the default is menu_order. You may also set order_by to either ‘custom’ or ‘numeric’ to sort on a custom field (see below).

order_2nd

Specifies the secondary sort column. If the values in the primary sort column are not unique, a secondary sort column is needed to fully sort the posts. Valid values are ID, post_title, post_date, and post_modified (default is post_date).

For example, the following will sort the posts by menu_order first, but if some posts have the same menu_order, it will further sort those posts by title. This ensures that posts with the same menu_order will not be skipped.

<?php next_post_link_plus( array('order_by' => 'menu_order', 'order_2nd' => 'post_title' ) ); ?>

meta_key

Specifies which custom field to use for a custom sort. Posts not having that custom field are excluded. For example, to sort the next/previous post links on the custom field ‘event_date’:

<?php next_post_link_plus( array('order_by' => 'custom', 'meta_key' => 'event_date') ); ?>

If you want the custom field values to sort as integers rather than strings (for example, if you are storing timestamps in the custom fields, or if you don’t want to zero-pad the numbers), set order_by to ‘numeric’. This forces the custom field values to be converted to data type ‘int’ prior to sorting:

<?php next_post_link_plus( array('order_by' => 'numeric', 'meta_key' => 'event_timestamp') ); ?>

If no meta_key is specified, ‘custom’ is ignored and the function defaults to sorting on post_date.

post_type

Specifies the post type(s) of the next/previous links. Default is the post type of the current post. For example, the following would include both regular Posts, and the custom post type Events, in the navigation links. The string must be formatted exactly as shown here, with each post type enclosed in double quotes, and separated by commas:

<?php next_post_link_plus( array('post_type' => ' "post","event" ') ); ?>

The post_type parameter is intended for advanced users. 95% of the time there is no need to set this parameter; the plugin is smart enough to auto-detect custom post types and deal with them correctly. The only reason you would need to specify the post_type is if you are trying to do something weird like having posts from two different types appear in the same navigation stream.

loop

If loop is set to true (or 1), then the next post link will loop around to the first post if there is no next post (and vice versa). The default is false (no looping). For example, if I want the next post link to lead back to “Alligator” once I get to “Zebra”:

<?php next_post_link_plus( array('order_by' => 'post_title', 'loop' => true) ); ?>

end_post

If end_post is set to true, the function will output the ending post in the navigation stream. For previous_post_link_plus, this will be the first post. For next_post_link_plus, it is the last post:

<?php previous_post_link_plus( array('end_post' => true) ); // outputs the first post ?>
<?php next_post_link_plus( array('end_post' => true) ); // outputs the last post ?>

The end_post parameter is primarily used for creating First|Previous|Next|Last navigation links. The default value of end_post is false, so unless you are trying to create First|Last links, you can omit this parameter entirely. In the following example, the First and Last links are created by setting end_post to true:

<?php previous_post_link_plus( array(
'end_post' => true,
'link' => 'First',
) ); ?> |
<?php previous_post_link_plus( array(
'end_post' => false,
'link' => 'Previous',
) ); ?> |
<?php next_post_link_plus( array(
'end_post' => false,
'link' => 'Next',
) ); ?> |
<?php next_post_link_plus( array(
'end_post' => true,
'link' => 'Last',
) ); ?>

By default, end_post does not return a first/last link when the current post is the first/last post. By setting end_post to ‘fixed’, you can force the first/last links to appear even when the first/last post is the current post:

<?php previous_post_link_plus( array(
'end_post' => 'fixed',
'link' => 'First',
) ); ?>

Note that end_post is not compatible with either looping or multiple links. When end_post is set to true, the loop and num_results parameters are disabled.

thumb

Displays the post thumbnail alongside the next/previous link. The default is false (no post thumbnail). Note that you may specify the thumbnail size to display. Valid values are true (i.e. the ‘post-thumbnail’ size), as well as all size values accepted by wp_get_attachment_image (e.g. ‘thumbnail’, ‘medium’, ‘large’, ‘full’).

Display the default ‘post-thumbnail’ size image:
<?php next_post_link_plus( array('thumb' => true) ); ?>

Display the ‘medium’ size image:
<?php next_post_link_plus( array('thumb' => 'medium') ); ?>

The thumbnail and link are given CSS classes named ‘post-thumbnail’ and ‘post-link’ to add in styling. By default, they appear next to each other, however if you want the link to appear underneath the thumbnail, add the following styles to your CSS file:

.post-thumbnail { float: left; }
.post-link { float: left; clear: left; }

max_length

Truncates the post titles to the nearest whole word under the length you specify, while adding three dots at the end to signify that the title was trimmed. Default is zero (do not truncate). For example:

<?php next_post_link_plus( array('max_length' => 25) ); ?>

This will trim The New York Giants Win Super Bowl XLII in Overtime to The New York Giants Win… The full title will be displayed in the tooltip when the mouse hovers over the link.

format, link

These parameters work the same as described in the WordPress Codex and in this article, with one difference: There are some extra variables that may be used in the ‘format’ parameter to add more information to your links. The %date variable outputs the date the post was published, while the %author variable prints the post author’s display name. The %category variable lists all categories and custom hierarchical taxonomies (PHP 5 only) to which a post belongs. For example:

<?php next_post_link_plus( array('link' => '%title', 'format' => '%link (posted in %category on %date by %author)') ); ?>

Produces something like this:

There is also a %meta variable that may be used only when using a custom sort order, and only when a valid meta_key has been specified. The %meta variable displays the meta_value of the next/previous post:

<?php next_post_link_plus( array('order_by' => 'custom', 'meta_key' => 'event_date', 'format' => '%link (Event date: %meta)') ); ?>

Finally, if you want to get rid of the default “arrows” on the links, remove ‘&laquo;’ and ‘&raquo;’ from the ‘format’ string. See the FAQ for more details.

date_format

Specify a date format to customize the display of the %date variable. You may use any of the date and time formats supported by WordPress. For example, to display the date in the format ’2010/11/06 at 12:50 AM’:

<?php next_post_link_plus( array('date_format' => 'Y/m/d \a\t g:i A') ); ?>

tooltip

Specifies the tooltip text to be displayed when the mouse hovers over the link. By default, the tooltip displays the full title of the post, but you can customize it:

<?php previous_post_link_plus('tooltip' => 'My previous post') ); ?> | <?php next_post_link_plus( array('tooltip' => 'My next post') ); ?>

You may also use the %title, %date, and %author variables in custom tooltip text. For example:

<?php next_post_link_plus( array('tooltip' => '%title posted on %date by %author') ); ?>

Finally, if you want to suppress the tooltip so that it does not pop up at all, set tooltip to false:

<?php next_post_link_plus( array('tooltip' => false) ); ?>

in_same_cat

Indicates whether or not the next/previous post must be in the same category as the current post. If set to true, only posts from the current category will be displayed. Note that if the current post is in more than one category, the next post link will lead to the next post in any of those categories. If this is not what you want, try using differential exclusion (see ex_cats_method below).

<?php next_post_link_plus( array('in_same_cat' => true) ); ?>

in_same_tax

Works exactly like in_same_cat, except with custom hierarchical taxonomies.

<?php next_post_link_plus( array('in_same_tax' => true) ); ?>

If you have multiple custom taxonomies, you may restrict the next/previous links to a specific taxonomy by passing the taxonomy name (that is, the name used in the first parameter of register_taxonomy):

<?php next_post_link_plus( array('in_same_tax' => 'my_taxonomy') ); ?>

For backward-compatibility reasons, in_same_cat works with both standard categories and custom taxonomies, but this may change in the future, so if you are using custom taxonomies use in_same_tax. If you have a situation where posts are assigned to both a standard category and a custom taxonomy, but you need to restrict the next/previous links to the same category only, then use this:

<?php next_post_link_plus( array('in_same_tax' => 'category') ); ?>

This makes sense when you realize that Categories are just like any other custom taxonomy, except that they happen to be predefined.

in_same_format

Works exactly like in_same_cat, except with Post Formats. Note that the %category variable will output the post format if, and only if, in_same_format has been set to true.

<?php next_post_link_plus( array('in_same_format' => true) ); ?>

in_same_author

Indicates whether or not the next/previous post must have the same author as the current post. If set to true, only posts by the current author will be displayed.

<?php next_post_link_plus( array('in_same_author' => true) ); ?>

in_same_meta

Indicates whether or not the next/previous post must have the same custom field value as the current post. You must pass the name of the custom field to be matched. For example, if you had a custom field named ‘publisher’, and you wanted the next/previous links to lead to titles from the same publisher:

<?php next_post_link_plus( array('in_same_meta' => 'publisher') ); ?>

Please note that in_same_meta is not compatible with custom field sorting. If order_by is set to either ‘custom’ or ‘numeric’, in_same_meta is disabled.

ex_cats

Specifies the category IDs to exclude from the next/previous links. Separate multiple category IDs with commas. For backward-compatibility reasons, the ‘and’ delimiter is also supported. In other words, both of the following delimiter styles are acceptable (but it is strongly recommended to use the comma-delimited style):

<?php next_post_link_plus(array('ex_cats' => '1, 5, 15')); ?><?php next_post_link_plus(array('ex_cats' => '1 and 5 and 15')); ?>

You may also exclude custom hierarchical taxonomies, and Post Formats (to exclude Post Formats you must use strong exclusion, see below). If you are having trouble finding the post format IDs, try using the Ambrosite Post Formats Widget.

ex_cats_method

Specifies the category exclusion method. Three exclusion methods are supported: strong, differential, and weak. The default is ‘weak’. The exclusion method determines how category exclusion works when you have posts in more than one category.

‘strong’ – All posts in the excluded category are excluded, even if the post is in more than one category, and the other categories are not excluded (ex_cats overrides in_same_cat).

‘diff’ – Posts in the excluded category are excluded, unless the post is in more than one category, and the other categories are not excluded.

‘weak’ – Posts in the excluded category are excluded, unless 1) the post is in more than one category, and the other categories are not excluded, or 2) in_same_cat is set to true and the current post is in the excluded category (in_same_cat overrides ex_cats). When in_same_cat is false, weak exclusion works exactly the same as differential exclusion.

Note that when using in_same_cat with either differential or strong exclusion, the posts in the excluded categories will not display any next/previous links at all. The following example excludes category ID 2, using differential exclusion:

<?php next_post_link_plus( array('in_same_cat' => true, 'ex_cats' => '2', 'ex_cats_method' => 'diff') ); ?>

If you are having trouble understanding how the exclusion methods work, please see the FAQ for further discussion.

in_cats

Specifies the category IDs to include in the next/previous links; also works with custom taxonomies. Separate multiple category/taxonomy IDs with commas. This parameter overrides both in_same_cat and in_same_tax — if you list any category IDs here, the next/previous links for all posts will be drawn only from those categories you specify.

<?php next_post_link_plus( array('in_cats' => '3,5') ); ?>

ex_posts

Specifies the individual post IDs to be excluded from the next/previous links. Separate multiple post IDs with commas. Note that ex_posts uses strong exclusion. Any posts you list here will be excluded no matter what the value of the other parameters.

<?php next_post_link_plus( array('ex_posts' => '3,7,12') ); ?>

in_posts

Specifies the individual post IDs to be included in the next/previous links. Separate multiple post IDs with commas. The posts listed here may be filtered depending on the settings of the other parameters. For example, if you exclude a category using ex_cats, any posts in that category will be excluded even if they are listed in in_posts.

<?php next_post_link_plus( array('in_posts' => '4,5,11') ); ?>

before and after

Text to place before and after the link(s). If no links are found, the before/after text is not displayed. Especially useful for formatting multiple links (see example below).

num_results

Returns multiple next/previous links. Default is 1. If this parameter is set to a value greater than 1, the next/previous links will be wrapped in <li> tags; you should surround them with <ul> tags by setting the ‘before’ and ‘after’ parameters. For example:


<?php previous_post_link_plus( array(
'order_by' => 'post_date',
'format' => '%link',
'link' => '%title',
'before' => '<h4>Older posts</h4><ul>',
'after' => '</ul>',
'in_same_cat' => true,
'num_results' => 3
) );?>

Causes something like this to be displayed:

Older posts

echo

If ‘echo’ is set to false, the functions will not echo any output to the screen. Instead, they will return the link(s) as a PHP string. This parameter is deprecated as of version 2.4. Please use the ‘return’ parameter instead.

return

Specifies what is returned from the functions. For example, if you wanted to retrieve the post ID of the next post, rather than the formatted link:

<?php next_post_link_plus( array('return' => 'id') ); ?>

The following options are supported. If any of these options are set, the functions do not echo anything to the screen, instead they only return the requested value. Please note that ‘object’ and ‘output’ are the only options that work with multiple posts (i.e. num_results > 1).

  • ‘id’ – Return the post ID.
  • ‘title’ – Return the post title.
  • ‘date’ – Return the “published on” date (i.e. the post_date) in the format specified by the date_format parameter.
  • ‘href’ – Return the post permalink (i.e. the value of the href attribute). Useful for those who want to append a query string to the permalink.
  • ‘object’ – Return the post object. If num_results > 1, an array of post objects will be returned.
  • ‘output’ – Return the complete output of the function as a PHP string.

If the ‘return’ parameter is not set, then the functions simply return true or false depending on whether any links were found. This makes it easy to create alternate styles in the event that there is no next/previous post. For example, if you wanted to have grayed out inactive links as described in this article, you can test the return value as follows:

<?php if ( !previous_post_link_plus() ) {
echo '<span class="inactive">&laquo; Previous</span>'; // if there are no older articles
} ?>

Note that if the $loop parameter is set to true, the function will never return false, since an adjacent post will always be found.

Complete Example

The following pair of template tags cycle through all posts in alphabetical order, within the same category, with looping but no post thumbnails, using the default link title and format with custom tooltip text, truncating the title to the nearest whole word under 30 characters, and excluding posts 5 and 12:


<?php previous_post_link_plus( array(
'order_by' => 'post_title',
'loop' => true,
'max_length' => 30,
'tooltip' => 'Previous post',
'in_same_cat' => true,
'ex_posts' => '5, 12'
) );?> |
<?php next_post_link_plus( array(
'order_by' => 'post_title',
'loop' => true,
'max_length' => 30,
'tooltip' => 'Next post',
'in_same_cat' => true,
'ex_posts' => '5, 12'
) );?>

Installation

  • Upload ambrosite-post-link-plus.php to the /wp-content/plugins/ directory.
  • Activate the plugin through the Plugins menu in WordPress.
  • Edit your template files, and replace the ‘next_post_link’ and ‘previous_post_link’ template tags with ‘next_post_link_plus’ and ‘previous_post_link_plus’. Configure them using parameters as explained above.

Frequently Asked Questions

How exactly do I install this plugin? Which file needs to be edited, and where do I put the code?

Unfortunately I cannot give specific instructions because every theme is different. In general, you need to find the template file that controls display of a ‘single’ post. This used to be a simple matter of finding the ‘single.php’ file and editing it, but with the proliferation of theme frameworks, child themes, template parts, and action hooks, things have gotten a lot more complicated. If your theme/framework has a community support forum, your best bet is to ask there; otherwise try the support forums at WordPress.org, and be sure to mention which theme you are using.

You can also download a free text search tool like grepWin and use it to search your template files for ‘next_post_link’. That will give you some idea of where to start. I use grepWin myself all the time to search the WordPress code for a particular function or variable.

I am getting a parse error while attempting to install the plugin. Why?

The plugin is not compatible with PHP 4. If you cannot upgrade to PHP 5, you can download the alternate PHP 4 compatible version of the plugin here. The only difference with the PHP 4 version is that the %category variable will not work with custom taxonomies.

I am getting a “call to undefined function” error. Why?

First, make sure the plugin is installed and activated before you edit your templates. Verify that the function names are spelled correctly. Also, make sure you are using the right plugin: Next/Previous Post Link Plus is intended for use in single post templates, while Next/Previous Page Link Plus is intended for use in page templates. The two plugins have similar sounding, but different, function names.

If you want to ensure that the functions will never produce a “call to undefined function” error, even if the plugin is deactivated, you can surround them with a ‘function_exists’ check:

<?php if ( function_exists('next_post_link_plus') ) {
next_post_link_plus(); // the function is only called if it is defined
} ?>

How can I get rid of the arrows on my next/previous links?

Technically, the “arrows” are called left and right angle quotes, and they are represented by the ‘&laquo;’ and ‘&raquo;’ HTML entity codes. They appear in the default ‘format’ as follows:

<?php previous_post_link_plus( array('format' => '&laquo; %link') ); ?>
<?php next_post_link_plus( array('format' => '%link &raquo;') ); ?>

If you want to get rid of them, simply remove the entity codes from the ‘format’ string:

<?php previous_post_link_plus( array('format' => '%link') ); ?>
<?php next_post_link_plus( array('format' => '%link') ); ?>

I am confused about the difference between strong, differential, and weak exclusion. Which one should I use?

Don’t feel bad, it is confusing. If you are in doubt, try using differential exclusion first. Judging from the feedback I have received, that is what most people want. If you don’t like the results you get from differential exclusion, then try strong exclusion. I do not know of any situation in which weak exclusion would be useful, but I kept it as the default since that is how it works in WordPress core.

Just remember that, when using in_same_cat with either differential or strong exclusion, the posts in the excluded categories will not display any next/previous links at all. This is to be expected, since you have excluded them from the next/previous navigation stream. If that is not acceptable, then your only alternative is to use weak exclusion.

I am using a custom field with a simple integer value to order my posts, but they’re not sorting correctly. Why?

New answer: Use a ‘numeric’ sort rather than a ‘custom’ sort to convert the custom field values to integers, and they will sort in correct numerical order.

Old answer: You need to zero-pad the integers if you want them to sort numerically. (’001′, ’002′, ’010′, etc.) This is a side effect of the WordPress data design. The ‘meta_value’ field in the wp_postmeta table is defined as type ‘longtext’. This means that any integer stored in the meta_value field is automatically converted into a string. Therefore any sort on the meta_value field is a string sort, not an integer sort. In a string sort, ’10′ comes before ’2′. That is why it is necessary to zero-pad the integers in order to sort them numerically.

I am seeing the number ’1′ printed next to my links. Why?

Several people have reported a mysterious trailing ’1′ appended to their next/previous links. The most likely cause is that you trying to echo the output of next_post_link_plus, like this:

<?php echo next_post_link_plus(); ?>

You don’t need to do that. The function echoes the link to the screen before it returns (assuming you have not set the ‘return’ parameter). The return value of the function is either Boolean true or false, depending on whether a next/previous link was found. When a Boolean ‘true’ is echoed to the screen, it is printed as ’1′. So just get rid of the unnecessary echo, and the problem will be solved.

What about compatibility with the Post Types Order plugin?

As of version 2.4, Next/Previous Post Link Plus defaults to sorting on ‘menu_order’ if Post Types Order is installed, so the two plugins should work together automatically now. If for some reason it is not sorting correctly, set order_by to ‘menu_order’:

<?php next_post_link_plus( array('order_by' => 'menu_order') ); ?>

Also, with Post Types Order you must open the ‘Re-Order’ tab on every one of your post types and click ‘Update’, even if you do not change the post order. This must be done at least once to set the ‘menu_order’ field in the database.

What about compatibility with the WPML plugin?

One of the users of Next/Previous Post Link Plus sent me a patch to make it compatible with WPML. I have not had an opportunity to test this patch myself, however here is the code in case anyone wants to give it a try. If this patch works for you, please let me know, and I’ll consider including it in the next version of the plugin.

<?php
// replace line 204 with the following code
global $table_prefix;
if ( function_exists('icl_sitepress_activate') ) {
$result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p,{$table_prefix}icl_translations AS icl_translations $join $where
AND p.ID = icl_translations.element_id AND icl_translations.language_code = '" . ICL_LANGUAGE_CODE . "' $sort");
} else {
$result = $wpdb->get_results("SELECT DISTINCT p.* FROM $wpdb->posts AS p $join $where $sort");
} ?>

What about compatibility with the qTranslate plugin?

A few people have reported problems when using Next/Previous Post Link Plus with qTranslate. I do not have a solution for this, however one person reported that he was able to solve the problem by using the patch given in this blog post:

http://www.choong.nl/2011/04/10/qtranslate-and-get_permalink/

Is there any way to use an image instead of link text?

Yes. First of all, if you are using WordPress 2.9 or higher, the plugin has built-in support for post thumbnails, so you should consider using them. Otherwise, something like this will work:


<?php previous_post_link_plus( array(
'format' => '%link',
'link' => '<img src="images/prev.png" />'
) );?>
<?php next_post_link_plus( array(
'format' => '%link',
'link' => '<img src="images/next.png" />'
) );?>

Changelog

2.4

  • Added ‘in_cats’ parameter.
  • Added ‘in_same_meta’ parameter.
  • Added ‘return’ parameter to specify what should be returned from the function.
  • Added ‘date_format’ parameter for customizing the %date variable.
  • Added %title variable to ‘format’ parameter.
  • Added option to sort on custom fields as integers rather than strings.
  • Primary sort column defaults to ‘menu_order’ if Post Types Order plugin is installed.
  • Many documentation updates to address frequently asked questions.

2.3

  • Added ‘in_same_author’ parameter.
  • Added ‘in_posts’ parameter.
  • Added ‘post_type’ parameter.
  • Added option to specify a custom taxonomy with ‘in_same_tax’.
  • Added new format variable (%author).
  • Added variables (%title, %date, %author) to custom tooltip text.
  • Added option to suppress the tooltip completely.
  • Renamed filters for compatibility with Post Types Order and other plugins that attempt to filter the output of get_adjacent_post.

2.2

  • Added option to retrieve the first/last post links as per user request.
  • Added support for post formats.
  • Improved support for custom taxonomies.
  • Added ‘tooltip’ parameter to specify custom tooltip text in response to Adam.
  • Added %meta variable to the format parameter as requested by Dan.
  • Ground-up rewrite of the ‘ex_cats’ functionality, with three exclusion methods for greater control over the navigation stream.
  • Added ‘ex_posts’ parameter to exclude individual post IDs.
  • Added option to return the next/previous links as a PHP string.

2.1

  • Added ‘order_2nd’ parameter for specifying a secondary sort column.
  • Updated the documentation to address PHP 4 incompatibility problems.

2.0

  • Full WordPress 3.0 compatibility, including custom post types.
  • Rewrote the plugin using wp_parse_args to simplify the function calls.
  • Added option to sort the next/previous links on custom fields.
  • Added option to return multiple next/previous links.
  • Added %category variable to the format parameter.
  • Fix for custom taxonomies as per user request.
  • Added ‘before’ and ‘after’ parameters in response to Hieu.
  • Added support for post thumbnail sizes as requested by Eduardo Malheiros.
  • Added ‘echo’ parameter in response to 13489.

1.1

  • Added truncate link title and loop options.
  • Added support for post thumbnails.

1.0

  • Initial version.

More Plugins

Comments

  1. James says:

    This is so useful. I’ve installed this plugin and activated it. I tried to add the first example php code you supply above into my single.php. The problem is posts hang when it reaches that php statement, so nothing else loads and I get half a page show up. What would cause that?

  2. ambrosite says:

    Thanks for your feedback. If the post hangs, it could be that the plugin is stuck in an infinite loop, searching for the next/previous post. I encountered this bug during testing but I thought I had fixed it. Would you please give me the exact code you are using in your single.php? A link to your WordPress site would also be very helpful.

  3. ambrosite says:

    I just thought of something else: are you using permalinks? If not, you might need to sort on ‘post_title’ rather than ‘post_name’ (assuming you want to move through the posts in alphabetical order).

  4. danny says:

    no loop doesn`t seem to work as it always loops

  5. ambrosite says:

    For anyone having trouble with the looping feature: please give me the link to your WordPress site, and the exact code you are using in your template. I am using the plugin on three of my own sites and I am not having this problem, so I’ll need some help to troubleshoot.

  6. danny says:

    i don’t really mind the loop but the post_name seems to numbers that well it seems to skip numbers if say theres a 1 and a 10 in the category or 2 to 20 so i guess it only recognize 0 to 9

  7. ambrosite says:

    @danny That’s because the post_name is stored in the database as a string, not an integer. On a string sort, ’10′ comes between ’1′ and ’2′. If you want those names to sort in numerical order, you need to pad them with leading zeros: ’001′, ’002′, … ’010′, etc. Either that, or start numbering at 101.

  8. GZ says:

    Thanks for this plugin – I think I’ll be able to make it work to meet my needs. The $in_same_cat feature works great until I hit a post that is in more than one category – then the links take me on a meandering route through all “connected” posts. For example, say I have thee posts in foo, three posts in bar, and one post in in both foo and bar. If I select an archive of foo posts, the previous and next links will take me through posts in both categories. If one of the bar posts is in an additional category the links will take me through all of those posts too. Is there any way to make the links browse only posts within the originally selected category?

  9. ambrosite says:

    @GZ The problem you are describing is inherent in the core next/previous_post_link functions. I did not change the in_same_cat functionality at all. Unfortunately there is no way to fix it, given how the get_adjacent_post function works. The best I could do would be to add a feature to explicitly include certain categories — that is, you could specify a list of category IDs that the next/previous links should browse. However, that would not help you unless you create custom single post templates.

    You might also check out this plugin. I’ve never used it myself, but the author is well-regarded, and I’ve heard other people have used it with success: http://wordpress.org/extend/plugins/smarter-navigation/

  10. Miss A says:

    Hi. I know almost nothing about editing php, but you mention under installation that the edits should take place in single.php? I don’t have any such file so I pasted the code you had under the FAQ “adding image instead of link” section into my index.php file. I named my images prev.png & next.png, put them in the image folder of my current theme, but nothing shows up at all, so I guess putting the code in index.php doesn’t work? Or have I totally missed something else?

    Hope you can help.
    Thanks!

  11. ambrosite says:

    @Miss A – It won’t work in index.php. You need to put it in the template that displays individual posts. In the default theme, that template is called single.php. Which theme are you using?

  12. Miss A says:

    I am using a graphically customized version of “fazyvo”, but the php code hasn’t changed, only the css. However, there does not seem to be any single.php as far as i can find in the main folder anyway. :(

  13. ambrosite says:

    @Miss A – I just downloaded the Fazyvo theme, and you’re right, it does not have a single.php template. That theme is using index.php for everything (according to the WP template hierarchy, WP falls through to index.php when there is no more specific template available). You can add the next/previous post functions there. At the bottom of index.php, you should see something that looks like this:

    <?php if (is_single() || is_page()) {} else {?>
    <p class="nav_link">
    <?php posts_nav_link(' &nbsp; ', __('« Newer Posts'), __('Older Posts »')); ?>
    </p>
    <?php } ?>

    You need to edit that as follows:

    <?php if (is_single() || is_page()) { ?>
    <p class="nav_link">
    <?php previous_post_link_plus('post_date', 'no loop', 'no thumb', '%link', '<img src="images/prev.png" />'); ?> &nbsp; <?php next_post_link_plus('post_date', 'no loop', 'no thumb', '%link', '<img src="images/next.png" />'); ?>
    </p>
    <?php } else {?>
    <p class="nav_link">
    <?php posts_nav_link('   ', __('« Newer Posts'), __('Older Posts »')); ?>
    </p>
    <?php } ?>

    Notice that you are placing the code inside the conditional that tests for a single post.

  14. GZ says:

    Thanks, Ambrosite – I’ll check out that plugin

    Miss A: Your theme may be using a different file to display posts. Here’s a hacky way to figure out which file you’ll need to edit. Down at the bottom of your template files (archive.php, single.php, index.php, etc..) , near the closing body tag, insert an html comment with the name of the file, then view your site and on the page where you want the navigation to appear, view the source, scroll down to see your comment and see which page is being used. This article may also be helpful: http://codex.wordpress.org/Template_Hierarchy

  15. GZ says:

    I’ve searched the codex for this and haven’t found an answer. Is there a way that I can check (programatically) to see if the Next/Previous plugin is active, so that I can load the default previous / next links if it isn’t? Thanks!

  16. ambrosite says:

    @GZ You could use PHP function_exists to check for the existence of ‘next_post_link_plus’ (if it doesn’t exist, the plugin is not active).

    http://php.net/manual/en/function.function-exists.php

  17. Miss A says:

    Hi again. Thank you so much for trying to help!

    I found that block of code at the bottom of index.php and edited it (actually, just pasted in your code) according to your instructions. Unfortunately no nex/prev arrows are showing up anyway :(. Can you see anything else I may need to alter?

  18. ambrosite says:

    @Miss A – Make sure the PNG files are in the right place. They should be in the ‘images’ folder, underneath the ‘fazyvo’ folder. If you’d like to post the link to your WP site, I’ll take a quick look and see if I can spot anything else that might be causing a problem.

  19. Miss A says:

    Hi, yes they are in fazyvo/images, and the names are correct.
    link is http://www.binah.nu/orbit. At the moment there are no next/prev links at all on the site, should that be default for wordpress? Is there some code hiding it somewhere perhaps?

    Well, take a look and see if you spot anything suspicious ;)

  20. ambrosite says:

    @Miss A – For some reason the relative file paths don’t seem to be working. Try using absolute paths instead:

    http://binah.nu/wordpress/wp-content/themes/fazyvo/images/next.png

    http://binah.nu/wordpress/wp-content/themes/fazyvo/images/prev.png

  21. Miss A says:

    Changed the links, still no go :(

    Maybe the theme is the problem.. unfortunately i can’t change that now.

  22. ambrosite says:

    Are you sure? I tested the fix myself using Firebug and it worked. Here is the exact code you need to paste into your template. Note that the links will not appear unless you are viewing one of the single posts (they will not show up on the home page):

    <?php if (is_single() || is_page()) { ?>
    <p class="nav_link">
    <?php previous_post_link_plus('post_date', 'no loop', 'no thumb', '%link', '<img src="http://binah.nu/wordpress/wp-content/themes/fazyvo/images/prev.png" />'); ?> &nbsp; <?php next_post_link_plus('post_date', 'no loop', 'no thumb', '%link', '<img src="http://binah.nu/wordpress/wp-content/themes/fazyvo/images/next.png" />'); ?>
    </p>
    <?php } else {?>
    <p class="nav_link">
    <?php posts_nav_link('   ', __('« Newer Posts'), __('Older Posts »')); ?>
    </p>
    <?php } ?>

  23. Miss A says:

    Yes, same code, not getting it to work :(
    If i can somehow PM you I can send you a login with a temporary password. Otherwise i think i may have to give up unfortunately.

  24. GZ says:

    Thanks, ambrosite – that is exactly what I was looking for!

  25. ambrosite says:

    But it IS working. Look at this post (down at the bottom, underneath the comment form):

    http://binah.nu/orbit/?p=255

    The next and previous post links will only appear on individual posts, not on the home page, and not on the category archive pages. If you are confused, please read this article, it explains all the different kinds of WP navigation and how they work:

    http://digwp.com/2009/08/wordpress-page-navigation/

  26. Miss A says:

    Yeee, yes it IS working now! :))

    Had to check the single posts again after the last change, and voila! However, the links are now at the very bottom of the page under the comments field. Is it possible to move them up, either to the top of the page or the bottom of the post above comments?

    THANKS for you kind help :)

  27. Miss A says:

    (Cross posted with you there, I guess we saw it at the same time.. ;)

  28. ambrosite says:

    @Miss A – The questions you are asking now are general template editing questions that really have nothing to do with my plugin. Basically you need to move that code block I gave you up higher in index.php. If you need specific instructions, you could try asking the creator of the Fazyvo theme:

    http://www.noonnoo.com/wordpress/my-free-wordpress-themes/fazyvo_1-6/

  29. Miss A says:

    I understand. I worked it out though and all is functioning great now. Yes, the code was simply too “low down” on the page.

    Thanks again for all your help. Very happy with your plugin now, so much easier to navigate between posts! :)

  30. Dave says:

    Nice plugin! Is there a way to display more than 1 post of each (two previous posts + two next posts)? I’ve been fiddling with the code, but can’t find what to change. Thanks!

  31. ambrosite says:

    @Dave Yes, it is possible, but it would require a fairly extensive rewrite. In brief:

    - Modify the LIMIT clause of the SQL query to return LIMIT n instead of LIMIT 1.
    - Use get_results instead of get_row to return an array of next/previous posts.
    - Use a foreach loop to display all of the next/previous posts.
    - Add an extra parameter to let the user specify how many next/previous posts should be returned.
    - Write the necessary conditionals to deal with the various scenarios.

    I’ll be releasing an updated version of the plugin once the WP 3.0 release is finalized; maybe I’ll consider adding this functionality at that time.

  32. anna says:

    Hi Ambrosite

    I am having problems getting the loop function working correctly. I can’t post a link as this is a client site however could give you one in private. The code I am using is

    |

    Your help would be very much appreciated

    Thanks

    Anna

  33. anna says:

    (php start)previous_post_link_plus(‘Previous’, ‘loop’); (php end) |
    (php start)next_posts_link_plus(‘next’, ‘loop’) (php end)

  34. ambrosite says:

    @anna The first parameter in the code you gave is incorrect. The first parameter is supposed to be the field to sort on (post_date, post_title, ID, etc). If the plugin does not find a valid field in that parameter, it defaults to sorting by post date.

    The second parameter looks OK to enable looping. Can you describe the problem you are having in greater detail? Is it not looping at all? Or is it hanging?

  35. anna says:

    lol it was me being stupid and uploading it to the template folder instead of the theme folder. Now it is in the right folder I understand, so my next question is how can I title my links previous and next?

    Sorry for the confusion earlier it has been a long and complicated development, the dizzy blonde is now kicking in. Thanks for the amazingly fast response.

  36. ambrosite says:

    The link title goes in the ‘link’ parameter. That parameter has not changed at all from the core function. Please check the Codex, or this article, for examples:

    http://digwp.com/2009/08/wordpress-page-navigation/
    http://codex.wordpress.org/Template_Tags/previous_post_link

  37. Dave says:

    Thanks for the quick response and suggestions ambrosite. Unfortunately, I’m not very good at PHP so I wasn’t able to implement those changes. However, I was able to get it to display how I wanted it by duplicating your code and commands with some small adjustments (next_posts_link_plus2, previous_post_link_plus2, etc.). Hopefully I didn’t screw any of the inner code while editing! I’m not sure how efficient it is, but it is working and it’ll do for now. Thanks!

  38. ambrosite says:

    @Dave Your solution sounds a bit messy, but if it’s working for you, that’s the important thing. Interesting question though, I will look into adding that feature in the next version of the plugin.

  39. Great plugin. Very helpful. I have one problem though I was hoping you could help me with. I am having trouble getting the “exclude category” feature to work. I would like to put certain posts in a single category that would get skipped over by the next/previous buttons. The documentation seems say that if I set something like this

    it should work. But it doesn’t. At first I thought that it was because the post I’m trying to skip shared a category that was not excluded. (That is it’s in both the Skip and Portfolio categories). But I can’t get the plug-in to exclude it even if I exclude every category that the post is in.

    Is this a bug or am I doing something wrong?

    Here’s the actual code in my single.php file:

    <?php if ( !previous_post_link_plus('post_date', 'no loop', 'no thumb', '%link', 'Older »', TRUE, '3 and 12 and 24 and 93') ) {
    echo 'Older »’; // if there are no older articles
    } ?>

    93 is the category I really want to skip, and the other three are all the other categories of the skip-worthy post.

    Here’s the page that should NOT have a link to the previous post.
    http://www.browningporterdesign.com/?p=158

  40. ambrosite says:

    @Browning Porter The problem is that you are missing the $max_length parameter, so the exclusion list is being passed as the wrong parameter (and therefore not processed correctly). You need to insert an extra parameter ’999′ before TRUE.

    And in fact, since you are not using any of the special features of my plugin (link reordering, looping, thumbnails, truncation, return values), you really don’t need my plugin at all. You could just use the core next/previous functions as described in the Codex:

    http://codex.wordpress.org/Template_Tags/previous_post_link

  41. ambrosite says:

    @Browning Porter Taking a closer look at your code, I see that you are testing the return value, so you do need my plugin for that. Inserting the extra parameter should solve the problem with category exclusion.

  42. Thanks for the response. (It’s true I’m only testing the return value at the moment, but if I can get this category exclusion to work, I may use some of the other features.)

    I tried what you suggested, but I still can’t get it to work. Here’s my revised code:

    <?php if ( !previous_post_link_plus('post_date', 'no loop', 'no thumb', '%link', 'Older »', 999, TRUE, '3 and 12 and 24 and 93') ) {
    echo 'Older »’; // if there are no older articles
    } ?>

    But a little experimentation reveals that it doesn’t work as expected with previous_post_link either. The following yields the same disappointing results:

    As near as I can tell, as long as two posts share any category at all, the link will appear, regardless of what’s in the category exclusion parameter.

  43. Here’s that other bit of code — also didn’t work:

    previous_post_link(‘%link’, ‘Previous in category’, true, ’3 and 12 and 24 and 93′);

  44. ambrosite says:

    @Browning Porter If it’s not working in the core function, I don’t know what to tell you. My purpose in writing the plugin was to add some extra functionality to the next/previous links that I found useful, not to track down bugs in the WordPress core. I suggest you report your findings to WordPress; if they issue a fix, I will incorporate it into my plugin.

    http://codex.wordpress.org/Reporting_Bugs

  45. Yeah, thanks. I wasn’t asking you to fix the core function. Just wanted to let you (and anyone else who might read this) know that it doesn’t actually seem to be a problem with your plug-in after all.

  46. It looks like this bug has been bouncing around WP for half a decade. For what it’s worth, I found this:

    http://wordpress.org/support/topic/290025#post-1280578

    By doing what this guy did to your plugin, I was able to get it work close enough to what I need.

    I’d hoped to create a “skip” category, and then exclude that. But trouble is, in order to exclude a post, you have to exclude EVERY category that it’s in, and then any post that shares some subset of those categories will also be skipped UNLESS you give it an additional category like “don’t skip.” Pretty kludgy, but it’s better than nothing.

    Thanks again for the great plugin and for your help.

  47. ambrosite says:

    @Browning Porter Thanks for the update. I am always reluctant to change the way the default parameters work, since that would break backwards compatibility with the core functions. In this case, it looks like the exclude categories parameter is not working anyway, so if I ever find a more elegant way of doing it, I will include it in my plugin.

  48. Rhys says:

    Thanks for the plugin.

    I would also like to see the option to display the next/prev post’s category (as a hyperlink to the archive page) just like you can display the title using %title. This would then allow the next/prev links to be displayed without restricting to the current category, but the indication of what it belongs to.

    What would be the best way to handle this?

  49. ambrosite says:

    @Rhys I will look into adding the category feature in the next version of the plugin. One problem I am running in to is that the functions already have too many parameters, and the function calls are becoming unwieldy. In order to add more features, I will probably have to rewrite the functions to use wp_parse_args. Unfortunately that would break backward compatibility with both the core functions and the current version of the plugin. I’m trying to find out if there is a way around that.

  50. ArtGoddess says:

    Hello!

    Seems a nice plugin… can this handle navigation between custom post types in a certain taxonomy ordered by “order” attribute?

    Thank you!

  51. ambrosite says:

    @ArtGoddess By “order” attribute, do you mean “menu_order”? (There is no “order” field in the wp_posts table.) The plugin can sort posts by menu_order. I have not yet tested it with WP 3.0 custom post types, but I will add that to the to-do list for the next version of the plugin. In the meantime, if you do any testing of your own, please let me know the results.

  52. ArtGoddess says:

    Thank you ambrosite,

    Exactly, I was meaning “menu_order”. What I want to achieve is explained in this post: http://bit.ly/a5HgO5 Does your plugin support or will support navigating this way?

    I will install your plugin and I will test it.

    Thank you!

  53. ArtGoddess says:

    @ambrosite Installed and testing, seems it is working between custom post types. Just a detail, I am not able to set the last parameter to TRUE. When I do that, there is no way to load the page of the custom post type.

  54. ambrosite says:

    @ArtGoddess Thanks for reporting the results of your test. As far as setting the last parameter to TRUE: that restricts the next/previous links to the current category. I’m not positive, but I think there might be some differences in the way WP 3.0 handles category relationships for custom post types. I’ll be doing some more testing with WP 3.0 over the next couple of weeks; if I find out any more details I’ll post them here.

  55. ArtGoddess says:

    @ambrosite Thank You! :-)

  56. themil says:

    Having a few troubles implementing this into a ‘MAP’.

    This is my code:

    - – - – - – - – - – - – - – - – -
    <img src="/explorer_client/cat_name;?>-category-top-bar.png” alt=”" width=”1280″ height=”90″ border=”0″ usemap=”#Map” />

    <area shape="circle" coords="142,43,40" href="” />
    <area shape="circle" coords="343,43,37" href="../category_nicename;?>” />
    <area shape="circle" coords="829,43,39" />
    <area shape="circle" coords="1147,43,39" />

    - – - – - – - – - – - – - – - – -

    What happens is that it will return the next post but both Previous and Next will be the same and when I click to go to that post, it will continue to link to that very post even though it is already on it.

    I also edited the plugin file to this in a section to this:

    - – - – - – - – - – - – - – - – -
    function previous_post_link_plus($order_by = ‘post_date’, $loop = ‘loop’, $thumb = ‘no thumb’, $format=’%link’, $link=’%title’, $max_length = 9999, $in_same_cat = true, $excluded_categories = ”) {
    return adjacent_post_link_plus($order_by, $loop, $thumb, $format, $link, $max_length, $in_same_cat, $excluded_categories, true);
    }

    function next_post_link_plus($order_by = ‘post_date’, $loop = ‘loop’, $thumb = ‘no thumb’, $format=’%link’, $link=’%title’, $max_length = 9999, $in_same_cat = true, $excluded_categories = ”) {
    return adjacent_post_link_plus($order_by, $loop, $thumb, $format, $link, $max_length, $in_same_cat, $excluded_categories, false);
    }
    - – - – - – - – - – - – - – - – -

    Thanks. Michael.

  57. ambrosite says:

    @themil I don’t know, image maps went out of fashion around the same time as Geocities, and I’ve never used one myself. My suggestion is to try and get it working using the core WordPress functions first. If you can do that, it will help to narrow down why it isn’t working with my plugin.

  58. MoDaD says:

    Thank you for developing this plugin. It’s really helpful. I just wanted to follow-up on the issue that Browning Porter mentioned related to excluding categories.

    For some reason I cannot get post link plus to exclude categories, but when I use the normal previous_post_link it will exclude categories (my apologies is this has been answered above. I’m asking under the assumption that Browning Porter could not get categories to exclude even when using the default previous_post_link).

    For instance, this will not exclude categories 56 and 57:

    <?php previous_post_link_plus('post_title', 'loop', 'no thumb', '« %link’, ‘%title’, 999, FALSE, ’56 and 57′); ?>

    <?php next_post_link_plus('post_title', 'loop', 'no thumb', '%link »’, ‘%title’, 999, FALSE, ’56 and 57′); ?>

    But this will:

    <?php previous_post_link('« %link’, ‘%title’, FALSE, ’56 and 57′); ?>

    <?php next_post_link('%link »’, ‘%title’, FALSE, ’56 and 57′); ?>

    It is very unfortunate because your plugin seems to be the only way I can get prev / next to sort alphabetically without an overkill solution that alphabetizes everything. Any help you can offer is greatly appreciated.

  59. ambrosite says:

    @MoDad What version of WordPress are you using? I haven’t yet had a chance to do extensive testing with WP 3.0, but the changes relating to custom post types may be causing a conflict (even if you aren’t using custom post types). Also, try it with ‘no loop’ instead of ‘loop’ and see whether that makes any difference.

  60. MoDaD says:

    I am using WordPress 3.0 and to my knowledge I am not using custom post types. I have just now tried ‘no loop’ and it does not seem to change anything. Categories ’56 and 57′ are still not being excluded.

    I also tried to implement the fix that Browning Porter linked to, by changing this:

    array_map(‘intval’, explode(‘ and ‘, $excluded_categories));

    to this:

    array_map(‘intval’, explode(‘|’, $excluded_categories));

    in both the plugin and in /wp-includes/link-template.php and using ‘|’ as a separator instead of ‘ and ‘ where appropriate, like so:

    <?php previous_post_link_plus('post_title', 'no loop', 'no thumb', '« %link’, ‘%title’, 999, FALSE, ’56|57′); ?>

    Unfortunately, the categories were still not excluded, but otherwise the plugin continued to function as normal.

    Thank you for taking the time to respond. If this is a WordPress 3.0 issue then that is understandable. I’ve heard that there’s a lot of things that were changed in the back-end that could be causing a number of plugin problems.

    Hopefully they won’t inhibit this plugin, as it is very useful and seems to be the only one of its kind. Thanks again.

  61. ambrosite says:

    @MoDad Thanks for the update. Yes, there were a great many changes made to the WordPress code to support custom post types. That’s why I haven’t done much with it yet; I wasn’t planning to use it in any of my projects until a few patches had been released. These articles sum up my reservations about WP 3.0 and custom post types quite well:

    http://ottopress.com/2010/my-recommendation-for-wordpress-3-0/

    http://ottopress.com/2010/wordpress-3-0-and-custom-post-types/

  62. MoDaD says:

    I started over completely from scratch and the plugin seems to be working great now. I’m not sure why my install wasn’t working correctly. I can now exclude categories without a problem:

    <?php previous_post_link_plus('post_title', 'no loop', 'no thumb', '« %link’, ‘%title’, 999, FALSE, ’56 and 57 and 58 and 59 and 60 and 61′); ?>

    You wouldn’t happen to know off-hand if it’s possible to have category’s children excluded without having to specify every sub-category, would you?

    Anyway, thanks again for your help!

  63. ambrosite says:

    @MoDad I’m glad to hear the plugin is working for you now. As far as excluding all child categories: it might be possible, but it would require a rewrite of the get_adjacent_post function. One way to do it might be to call get_categories with the ‘child_of’ parameter to find the descendant categories of every category in the exclusion list, then merge all the resulting arrays together and use that as the final exclusion list for the SQL query. That’s just a guess, based on what I’ve read in the Codex. It would have to be tested thoroughly, and it would not be pretty in any case.

  64. Mohib says:

    Hi,

    I’m using query_posts to sort my posts by a custom field (i.e. meta data) using

    query_posts($query_string.’&meta_key=Event_Date&orderby=meta_value&order=DESC’);

    and would like to have my next post and previous post links match this sort.

    This plugin has limited alternative sorting but doesn’t seem to allow meta data sorting for next and previous. Any suggestions on how I can do this.

    Thanks in advance for any help.

  65. ambrosite says:

    @Mohib It is possible to sort the next/previous posts on a meta value, however it would require a substantial rewrite of the get_adjacent_post function. I’ll add this to the long list of features to be included in the next version of the plugin (I’m hoping to make some progress on that this week, schedule permitting).

  66. ranpha says:

    The code that I use:-

    |

    It works just fine according to my needs, but I doesn’t like how it looks like.

    See picture below:-
    http://img823.imageshack.us/img823/599/examplede.png

    The output of the PHP snippet is:-

    [previous post] >> | [next post] >>

    But I want it to be

    <>

    What can I do to make it looks like the way I want it (as also seen in this blog)?

    I can also accept not having the ‘<>’

    Thanks.

  67. ranpha says:

    Some formatting lost there, sorry.

    See the complete text at http://img266.imageshack.us/img266/9835/textform.png

  68. ambrosite says:

    @ranpha Looking at the image you posted, you have the parameters backwards in your “previous” function. It should read:

    previous_post_link_plus(‘post_date’, ‘no loop’);

    But really, I don’t think you need my plugin at all. Since you are sorting the posts by date, and since you are not using any of the other special features of my plugin (looping, post thumbnails, title truncation, return values), you could just use the core functions as described in the WordPress Codex:

    http://codex.wordpress.org/Function_Reference/previous_post_link

    You should also read this article, it explains how to format the next/previous links to suit your needs. The methods described in the article work with both the core functions and my plugin:

    http://digwp.com/2009/08/wordpress-page-navigation/

  69. pixelprophet says:

    Thanks for this plugin; I was working hard to find a solution to using PostMash and making the navigation work according to the PostMash menu order (menu_order parameter works great with the Ambrosite nav links plugin!). Haven’t been able to get PostMash Filtered to work, which might have otherwise done the job, so this plugin saved the day.

    Top stuff.

  70. ambrosite says:

    @pixelprophet Thanks for the positive feedback. That is exactly why I created the plugin — I had a need to sort the next/previous links in one of my own projects, and I could not find any other solution.

  71. ambrosite says:

    I am currently seeking beta testers for version 2.0 of this plugin. Please see the blog post for more details, and to download the beta version.

  72. Eduardo Malheiros says:

    Is there any way to set the size of the thumbnail like it happens with the normal set-up, like thumbnail, medium and large?

    Thank’s!

  73. ambrosite says:

    @Eduardo Yes, it is possible. I will include that feature in version 2.0 of the plugin, which I expect to be releasing to the plugin directory this weekend.

  74. ambrosite says:

    I have updated the 2.0 beta with the thumbnail size feature requested by Eduardo:

    http://www.ambrosite.com/blog/seeking-beta-testers-for-nextprevious-post-link-plus-2-0

  75. Claire says:

    Hi, fantastic plugin, Is it possible to move the previous ‘title’ (I am using an arrow image) before the thumbnail, keeping the next ‘title’ after the thumbnail? ie . Thanks

  76. ambrosite says:

    @Claire Yes, if you enclose the next and previous links in separate divs, you can float the post thumbnails left or right within the divs. That will determine on which side of the image the title appears. For example, if you were to do this with the TwentyTen theme, the CSS would look like this:

    div.nav-previous .post-thumbnail { float: right; }
    div.nav-next .post-thumbnail { float: left; }

  77. ambrosite says:

    Version 2.0 of the plugin has been officially released. Please make sure you are using the latest version. The documentation on this page has been updated.

  78. KarenK says:

    Hi Ambrosite, This plugin looks like the perfect solution for my client’s site. However, when I attempt to install the plugin I get the following error:

    Parse error: syntax error, unexpected ‘&’, expecting T_VARIABLE or ‘$’ in /nfs/c06/h02/mnt/90145/domains/whpccorp.org/html/wp/wp-content/plugins/ambrosite-nextprevious-post-link-plus/ambrosite-post-link-plus.php on line 224

    Any idea what I can do to troubleshoot? I’ve disabled all other plugins, and deleted yours then re-installed it. No luck. Thanks in advance.

    I’m running Wp 3.01 and version 2.0 of your plugin. I have customized my permalinks and updated the .htaccess file as instructed by WP.

  79. Claire says:

    That worked perfectly, Thank you.

  80. ambrosite says:

    The error reported by KarenK was being caused by one line in the plugin that is not compatible with PHP 4. Karen was able to solve this by upgrading to PHP 5 — which really everyone should do, since WordPress has made an end of life announcement for PHP 4.

    However, for those who cannot upgrade to PHP 5 at this time, I have created an alternate, PHP 4 compatible version of the plugin. The only difference with this version is that the %category variable will not work with custom taxonomies. It may be downloaded here.

  81. vinh says:

    thank you so much for this. I’m using custom post types and PHPurchase to build a store and this saved me a lot of time and thinking!

  82. Thank you so much for the great plugin! I’m using it on two different types of posts and thought I’d share…

    I have Newsroom posts that have a special post template I’m using. I only want visitors to scroll through the newsroom posts. Easily achieved using:

    ‘date’, ‘loop’ => true, ‘max_length’ => 30, ‘in_same_cat’ => true) ); ?>

    But I also have regular ‘ol posts that I want to scroll through multiple categories but EXCLUDE both the Newsroom and Portfolio categories. Also easily achieved, though I needed to poke around a bit to get it to work) using:

    ‘date’, ‘loop’ => true, ‘max_length’ => 30, ‘in_same_cat’ => false, ‘ex_cats’ => ’101 and 103′) ); ?>

    Thanks a bunch for a great plugin!

  83. ambrosite says:

    @vinh, @Jann Thanks for your feedback! I’m glad to hear the plugin is working well for you.

  84. Steve says:

    Great plugin, however, using the PHP 4 version and PostMash, if I ‘order_by’ => ‘menu_order’, the links disappears entirely. If I set it to ‘post_title’ or ‘post_date’, it works exactly as expected. Any thoughts?

  85. ambrosite says:

    Steve fixed his problem by opening PostMash in the WP admin console and clicking “Update”. This is necessary in order to set the menu_order for each post, otherwise some posts will have menu_order=0 and then the plugin cannot sort them correctly (this only applies to people who are using the PostMash plugin and sorting on menu_order).

  86. Pylon says:

    Great plugin! I can’t believe that this isn’t default behaviour for WP…
    ambrosite, I’m running into an issue whereby I’m using a custom sort which is a number (a 1–5 film rating). Posts with the same rating value seem to cancel each other out — only one or the other appears. Any thoughts?

    Thanks again for a great plugin! :)

  87. ambrosite says:

    @Pylon Your problem is caused by a logic flaw in the SQL query that retrieves the next/previous post. When the values in the primary sort column are not unique, a secondary sort column is needed to fully sort the results. I’ve known about this problem for a while (this was also the cause of the problem Steve reported when sorting on menu_order), but I have just now found a way to solve it. Please download version 2.1 beta 1 here:

    [Beta link removed. Version 2.1 has been uploaded to the WordPress plugin repository.]

    This version includes a new parameter ‘order_2nd’ which is the secondary sort column. Valid values for order_2nd are ID, post_title, post_date, and post_modified (default is post_date). For example, the following function call will sort the posts by rating first, but if some posts have the same rating, it will further sort those posts by title. This ensures that posts with the same rating will not be skipped.

    next_post_link_plus( array(‘order_by’ => ‘custom’, ‘meta_key’ => ‘rating’, ‘order_2nd’ => ‘post_title’ ) );

    Give it a try, and let me know how it works for you.

  88. Pylon says:

    Ambrosite, that was fast! I think we’re almost there but I’m currently getting a MySQL query printed in the HTML code:
    ####################################################
    (query removed)
    ####################################################

    I've the plugin set to show 50 num_results just for testing. Same behaviour when it's set back to 1, however.

  89. ambrosite says:

    Oh my, that’s embarrassing! Yes, I forgot to comment out the code that prints the SQL query I use for testing purposes. I guess that’s why it’s called a ‘beta’. :) I’ll fix that before uploading to the repository.

    Two other things:

    1) Please post your function call here, so I can see what parameters you are using.
    2) Are any of these posts in more than one category?

  90. Pylon says:

    Haha, no worries A. :)

    Function call, below. Formatted for easier reading here:
    next_post_link_plus( array(
    ‘order_by’ => ‘custom’,
    ‘meta_key’ => ‘rating’,
    ‘order_2nd’ => ‘post_title’,
    ‘loop’ => false,
    ‘thumb’ => false,
    ‘max_length’ => 0,
    ‘format’ => ‘%link »’,
    ‘link’ => ‘%title’,
    ‘before’ => ”,
    ‘after’ => ”,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ”,
    ‘num_results’ => 50,
    ‘echo’ => true
    ) );

  91. Pylon says:

    None of the post are in more than one category.

  92. ambrosite says:

    Okay, I took out the line that prints the SQL query. The 2.1 beta 1 zip file I posted above has been refreshed.

    I don’t know why the plugin would return different results based on the value of num_results, unless you had some posts that were in more than one category. But since you say you don’t … I would need to see it in action on your site in order to troubleshoot any further.

  93. Claire says:

    Is it possible to remove the >> from the next & previous text?

  94. Pylon says:

    Thanks A — works like a charm. :)

    Claire, you can remove the >> by not including it here:
    ‘format’ => ‘%link »’,

  95. ambrosite says:

    Pylon, thanks for your feedback. Version 2.1 has been officially released, and uploaded to the WordPress plugin directory.

  96. river says:

    I’m using a simple integer meta_key to present custom post types in a specific order for a CMS-style deployment of WordPress. But the custom order_by seems to default to alphanumeric or date/time. This means that integers like this need to be zero-padded in order to get the correct sort order. Other than that, awesome plug-in and great documentation. Really appreciate the support for custom post types and taxonomies.

  97. ambrosite says:

    @river The need to zero-pad the integers has nothing to do with my plugn, rather it is a side effect of the WordPress data design. The ‘meta_value’ field in the wp_postmeta table is defined as type ‘longtext’. This means that any integer stored in the meta_value field is automatically converted into a string. Therefore any sort on the meta_value field is a string sort, not an integer sort. In a string sort, ’10′ comes before ’2′. That is why it is necessary to zero-pad the integers in order to sort them numerically. It would be impossible to change this behavior without altering the table definition.

    Note that you do not have this problem when sorting on menu_order, because the menu_order field is defined as type ‘int’. So if you want to use simple integers to sort your posts, it would be better to do it using a plugin like PostMash, which stores the values in the menu_order field. This is turning out to be a common question/problem, so I will add a note to the documentation.

  98. Raj says:

    I need next/previous navigation works only in the same category.That is other category post links should not be displayed.
    for example:in “Blogger” category only previous/next post links should be in “Blogger”.Not from other category
    I’m newbie to this.If it possible means share your ideas.thanks

  99. A u d e e says:

    Great plugin!
    I replaced the » with image with this function:
    ‘format’ => ‘ %link’
    But I don’t know why this ‘thumb’ => true, doesn’t work for my theme. I’m using wordpress 3.0.4 (modified twentyten) theme btw.
    The post thumbnails wp function is enabled on functions.php
    // This theme uses post thumbnails
    add_theme_support( ‘post-thumbnails’ );
    Please check it here: http://goo.gl/06aUC
    Could I use some helps from this discussion thread ~ thank you very much :)

  100. ambrosite says:

    @Raj You need to set the in_same_cat parameter to true, like this:

    ‘in_same_cat’ => true

  101. ambrosite says:

    @Audee Have you set a post thumbnail image for each post using the “Post thumbnail” meta box in the post editing screen? Follow the instructions in this article if you are confused:

    http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature

  102. Stuart says:

    Thanks for the plugin ambrosite. After a few months of being happy with the graphical look of my current WordPress theme, tonight I realised that my pages were missing next/previous links between posts.

    I am just wondering how to make the plugin only for ‘posts’ and not for ‘pages’? I have the same problem as user Miss A (above) where my theme does not have a single.php file – everything is in a file called content.php.

    Right now my pages ( http://www.recombinantrecords.net/subscribe/ http://www.recombinantrecords.net/about/ ) have ‘next’ and ‘previous’ links on them. I am using your original code solution for Miss A (above). Could you please advise how to turn this off for pages, but not for posts.

    Would be great if you could post a solution here and also send me a short email note to check these comments.

  103. ambrosite says:

    @Stuart This is more a general template editing question that you are asking, rather than anything specific to my plugin, but the basic strategy is to use the is_single conditional to display the next/previous post links only on single posts:

    http://codex.wordpress.org/Function_Reference/is_single

    If you copied and pasted the code I gave Miss A, then you would need to replace the first line:

    <?php if (is_single() || is_page()) { ?>

    with this:

    <?php if ( is_single() ) { ?>

  104. Adam says:

    Hi ambrosite, thanks for the great plugin. I’m wondering how i can change the tooltip text for when i hover over my next and previous links. Currently it just shows the title for the next or prvious post, but i’d like them to just say “newer” or “older”.

    Cheers!

  105. ambrosite says:

    @Adam You could make that change by inserting the following code just before line 229 of the plugin:

    $long_title = $previous ? ‘Newer’ : ‘Older’;

    Note that you might have to reverse the order of ‘Newer’ and ‘Older’ depending on how you have things set up:

    $long_title = $previous ? ‘Older’ : ‘Newer’;

  106. Adam says:

    Awesome, thanks for the quick reply. Keep up the great work!

  107. First of all, this plugin is great, my site design relies heavily on it for a large chunk of its navigation.

    I wanted to know, however, if there is a way to use it to generate the links to the first and last posts for whatever value it is sorting by?

    For instance, if I had it sorting by date and set to ‘in_same_cat’ => true, I could get it to generate links for the oldest and newest posts for that category?

  108. ambrosite says:

    @Different Adam: I am sure it is possible, but I would need to think about the best way to do it (it would require a change to the underlying SQL query, so it is not a trivial fix). I am currently putting together a wish list for version 2.2 of the plugin, so I will add your request to the list of features to be added.

  109. ambrosite says:

    Here is the official thread for version 2.2 feature requests. I plan on releasing 2.2 sometime after WP 3.1 is released.

    http://wordpress.org/support/topic/plugin-ambrosite-nextprevious-post-link-plus-version-22-wish-list?replies=1

  110. kirasherrine says:

    Hi Ambrosite,

    I first wanna say thank you for this plugin, it helped me override wp-pagenavi on single.php.

    I have version 3.0.1 WordPress and developing my own theme.
    But there was a problem coding it… for some odd reason it would not let me code it the way you listed it in readme.txt.

    I ended up having to manipulate the 1 and 0 to true and false on the URL query style string like this: (just to let you know)

    The problem is that thumb does not work (and I’ve written it like thumb=1 and thumb=true), I also checked the comments above and checked the link that you gave to a fellow with a similar problem. Mines is a bit different as it messes up anything below the code so my comment template, sidebar, and footer does not show. Unless I do not include thumb… which I really want…lol.

    Anything you can do on your end?

  111. kirasherrine says:

    (‘order_by=post_title&order_2nd=post_date&loop=true&max_length=35&in_same_cat=true&echo=false’)

    …sorry tag did not post… Its inside the php brackets

  112. Dan says:

    Thanks for this awesome plugin!

    I love that you can order it by a meta_key. Is there a way to use the meta_key as the %title within this plugin?

    Using get_post_meta($post->ID, ‘my_meta’, true); just returns the current pages meta_value.

    Any thoughts on this?

  113. ambrosite says:

    @kirasherrine Have you tried passing the parameters as an array rather than a query string? If you want me to troubleshoot further you would need to give me the link to your site.

  114. ambrosite says:

    @Dan Put the meta_key name in the ‘link’ parameter: ‘link’ => ‘my_meta’

  115. Dan says:

    Thanks for the quick response.

    okay my meta is ‘attorneyname’

    If I put that into ‘link’ => ‘attorneyname’

    It just says “attorneyname” for the navigation. It doesn’t show the actual value…

  116. ambrosite says:

    @Dan I understand what you mean now. That is possible, but it would require a code change. I am working on version 2.2 of the plugin now; I will add this to the list of features to be included in the next release.

  117. randy fritz says:

    I would like to ELIMINATE the next and previous link on my posts.
    I am trying to UNCLUTTER the look of my posts.
    Would this plugin help for that?

    What would you suggest.

  118. ambrosite says:

    @randy You don’t need a plugin for that. Just edit your single.php template and remove the calls to next_post_link and previous_post_link.

  119. Todd says:

    Thank you for the very clear instructions! This was stretching my minimal coding ability but I got it on the first try. ;)

  120. Dan says:

    @ambrosite Great! Looking forward to the new release.

  121. Tiffany says:

    Hi there. Just sent you an email about hiring you to do a modification of this plugin for a specific project I have. Thanks!

  122. Lawrence says:

    Great plugin, btw!

    One question about aesthetics… How do I insert a space or character between the two links, a la “|”?

  123. ambrosite says:

    @Lawrence Look at the “Complete Example” I gave in the documentation. That shows how to do it.

  124. Daniel says:

    Hi Ambrosite, thanks for this great plugin!

    I am using it with the qtranslate plugin and it seems like I need to modify the way titles are fetched from posts as to take into account which language is selected. This is the format qtranslate uses:

    FrancaisEnglish

    I had to modify another plugin to make it work with qtranslate, the way this worked was to enclose $post->post_title with __( )

    I looked at your code but can’t find where I should make the changes. Your help with this issue sure would be appreciated!

    Thanks again

  125. ambrosite says:

    @Daniel I am not familiar with the qtranslate plugin, however I can tell you that the title is being returned around line 243 of my plugin (first line of the foreach loop):

    foreach ( $posts as $post ) {
    $title = $post->post_title; // line 243 (version 2.2; line numbers may change in future versions)
    if ( empty($post->post_title) )
    $title = $previous ? __('Previous Post') : __('Next Post');

    I assume that is where you would need to make the change.

  126. Daniel says:

    Thanks for the quick reply, I found that line before and tried to adapt it, but it’s not working…

    Thanks anayway

  127. Dan says:

    @ambrosite –

    Thank you so much for adding the %meta feature! Seriously, this is a great plugin and I appreciate the work you have put into this.

    Dan

  128. Caroline says:

    Nice! Thank you!

  129. Profe says:

    A million thank you for the excellent plugin and the time and effort that you put into it.

    Just a quick question to know if what I did is “good” or “bad”.

    I wanted to change the ‘format’ => ‘%link »’, >> change the 2 greater than sign to a small arrow image for BOTH the previous and next posts. What I did is the following:

    Changed line 182 of the ambrosite-post-link-plus.php to the following:
    function previous_post_link_plus($args = ”) {
    return adjacent_post_link_plus($args, ‘ %link’, true);

    line 194 to:
    function next_post_link_plus($args = ”) {
    return adjacent_post_link_plus($args, ‘%link ‘, false);

    So basically I replaced the » with the path to my arrow images.

    I´m happy with the visual results now but just wanted to know if theres a “better” way to the “coding”.

    Thanks a Million for the wonderful plugin once again!!!

  130. ambrosite says:

    @Profe There is nothing wrong with what you did, except that it is not necessary. Those are just default values; anything you pass in the ‘format’ parameter will overwrite those values. The drawback to editing the code is that the next time you download a new version of the plugin your changes will be lost. You won’t have that problem if you pass the format as a parameter. Thanks for the feedback, I’m glad to hear you found the plugin helpful!

  131. John Murray says:

    Michael – Thanks for the great plugin. You can see it in use here:
    http://www.johnmurray-realtor.com/communities/va-vienna-maymont/

    That URL is to a custom post type with several custom taxonomies.

    I use several custom taxonomies: one for the county in which a community is located, one for the city, and one for the types of properties in the community.

    Is there a way to specify WHICH custom taxonomy is used for the ‘in_same_tax’ parameter? Right now, with ‘in_same_tax’ set to true, the next/previous links are returning the next/previous values from the custom post type, but I’d really like to include the next/previous value for 1 specific taxonomy: the city.

    Changes to category settings haven’t produced what I’m looking for.

    Thanks again for a great plugin.

  132. ambrosite says:

    @John It is possible with a hack. Go to line 88 of the plugin (version 2.2). It should look like this:

    $tax_array = wp_get_object_terms($post->ID, $taxonomies, array(‘fields’ => ‘ids’)); // line 88

    The $taxonomies variable is the array of all custom hierarchical taxonomies. If you want to restrict in_same_tax to one specific taxonomy, replace that variable with the name of the taxonomy you want (that is, the name used in the first parameter of register_taxonomy):

    $tax_array = wp_get_object_terms($post->ID, ‘city’, array(‘fields’ => ‘ids’)); // assuming your taxonomy is named ‘city’

  133. John Murray says:

    Wow. Great plugin and lightning fast answers that work. Many thanks.

  134. ambrosite says:

    @John You’re welcome. It is easy to be lightning fast when the code is kept clean and I have nearly every line of it committed to memory. :)

    And thanks for your feedback, by the way. I’ll add the option to choose a specific taxonomy in the next version.

  135. Pariah Burke says:

    Wonderful plugin!

    Is there a way to add the excerpt into the plugin’s output? That would be very useful as a “next post preview” type function.

  136. ambrosite says:

    @Pariah Burke Yes it is possible. The real question is: what would be the best HTML markup for that? I could put the excerpt inside span tags, but the link itself may be marked up as a span when thumbnail is set to true. It seems semantically messy to have two spans sitting right next to each other. I could mark the excerpt up as a paragraph, but then what about the case where a list of links is returned (when num_results > 1)? It is not really good HTML practice to put a paragraph inside a list item.

    Then of course there is other post data besides the excerpt that a person might want to output separately from the link: the post author, the post date, the meta value, etc. Anticipating those possibilities, it might be best to output all of this data inside another HTML list. You could potentially end up with lists inside of a list (in the case where num_results > 1); it would be a little complicated, but semantically valid and quite flexible.

    Well you’ve got me thinking anyway! Good suggestion, I’ll see about doing something like that in the next version of the plugin.

  137. Rebecca says:

    Thanks for this, great plugin. 5 starred on wp

  138. Thank you for the awesome plugin, saved my bacon! 5 starred on WP :)

  139. Pet Shops says:

    Thank you ambrosio for this nice plugin. I was installing it in my website and I had a problem I could not change the dimensions of the images to 60px and 60px width and heigth respectively to be fixed for any post.
    I manage to do that by inserting an array into the thum field like this:

    ‘thumb’ => array( 60, 60 )

    all worked fine and as I saw there is not something like that in this post, so i am posting this in order to help others.
    Regards

  140. ambrosite says:

    @Pet Shops Thank you for sharing that tip! I am sure the users of the plugin will find it helpful.

  141. Devin Walker says:

    Nice plugin, saved me when using Custom Post Types.

  142. Magnus says:

    Wow! Just what I was looking for. Thanks for creating this great plugin.

    You just got a 5 star rating wordpress.org! :)

  143. Travis says:

    Hey ambrosite,
    is there a way to include addtional details in the tooltip or format? I’d like to show the author name, date published, etc… in a tooltip on hover of “Next Post” and “Previous Post”. If I could include that info in the href’s title, that might work.

    What do you think?

  144. ambrosite says:

    @Travis Yes, it is possible, but it would require a code change. I am planning for a new version of the plugin around the same time that WordPress 3.2 is released, so I will look into adding this feature in the next version.

  145. r.e. brown says:

    Great plugin, but I’m recieving error messages on my image attachment pages inside the posts themselves.

    Warning: array_reverse() [function.array-reverse]: The argument should be an array in /home/swellco2/public_html/wp-content/plugins/ambrosite-nextprevious-post-link-plus/ambrosite-post-link-plus.php on line 240

    Warning: Invalid argument supplied for foreach() in /home/swellco2/public_html/wp-content/plugins/ambrosite-nextprevious-post-link-plus/ambrosite-post-link-plus.php on line 242
    |

  146. ambrosite says:

    @r.e. brown Thanks for reporting the error. I’ll investigate that and hopefully have a fix ready for version 2.3.

  147. Martin says:

    Great plugin — couldn’t get the loop function working, but disabling the Post Types Order plugin has fixed it. I’ll go back to ordering the posts the old fashioned way. (I’m running a portfolio site so I need the posts in a certain order).

    I was wondering if the tags could be made to work with the thumbGen plugin (http://wordpress.org/extend/plugins/thumbgen/), I would really like to make the thumbs grayscale. My php is not too good, I’ve tried a number of different ways but always turn up errors. I’ve used the Simple Image Size plugin to create a custom size for my thumbs, but just can’t get them to be grayscale!

    Any ideas?

    Keep up the good work, cheers!

  148. Rasheed says:

    Hello ambrosite,

    I read through this thread and I am still having trouble finding out how to display an image instead of « PREVIOUS: and the same for next. I would like the link to the next & previous post to still show but I just want to have a nice button in front of the previous link and behind the next link. I’m sure this code is somewhere in here but I’m just too confused. Will you guide me in a fix?

  149. ambrosite says:

    @Martin Yes, my plugin is currently incompatible with Post Types Order, but I am planning to fix that in version 2.3 (due for release after WordPress 3.2 comes out).

    I have never used the thumbGen plugin, and I don’t quite understand what you are asking, however navigating thumbnail galleries is really outside the scope of what my plugin is intended to be used for.

  150. ambrosite says:

    @Rasheed Check the FAQ, fourth question.

  151. Thanks it worked! the final problem I’m having is removing the « and » from the link area. I did my own searching for it but had no luck finding it. Would you please tell me where I can locate it?

  152. Ayek says:

    Hi,
    Let me track back to Daniel’s request about qTranslate.
    Are you able to modify your plugin, to aviod empty titles, and skip to titles which have any characters?

  153. Larry says:

    Excellent plugin and appears exactly something I am looking for. How do you exclude taxonomies though? I have some custom post types with multiple taxonomies and I only want to use one of those for those posts.

  154. ambrosite says:

    @Ayek I suppose it might be possible by modifying the SQL query, but in what situation would you have posts with empty titles?

  155. ambrosite says:

    @Larry That is a known limitation of the plugin that I am planning to fix in the next version. Please check this thread for a discussion and temporary workaround:

    http://wordpress.org/support/topic/in_same_tax-true-not-working

  156. Ayek says:

    I’ve found out that empty titles are correctly avoided only in default language, but in other langs empty titles gives empty next/previous links.
    In qTranslate plugin you must put one space in title field to designate translation as excluded from any displays (menus, listings etc.). It doesn’t work at Next/Previous :(
    I think it needs adjustments in qTranslate scripts, but if you’d come up with a fantastic idea, I’d be very happy.

  157. Neil Stoker says:

    I am trying this plugin because I have many contributors (~180) and I want to limit buttons on single.php to a single person’s posts. But they belong to at least 2 categories (one = their name, the other is a group category, and I want to exclude posts from people within the same group.

    All works well (same as basic wordpress) until I switch in_same_cat to true, and exclude the group category. It then works as I move from post to post, and then I see a blank page with “Error establishing a database connection”. Reading above, there was something about adding a second sort to make sure they are unique; I am ordering first with ID (should be completely unique), then post_title (should also be unique). Once I get the error, I keep getting it, even on pages that showed OK just before.

    My code is copied from your page and adapted:

    ‘ID’,
    ‘order_2nd’ => ‘post_title’,
    ‘meta_key’ => ”,
    ‘loop’ => false,
    ‘end_post’ => false,
    ‘thumb’ => false,
    ‘max_length’ => 0,
    ‘format’ => ‘%link’,
    ‘link’ => ‘ ’,
    ‘tooltip’ => ”,
    ‘in_same_cat’ => true,
    ‘in_same_tax’ => false,
    ‘in_same_format’ => false,
    ‘ex_cats’ => ’344′,
    ‘ex_cats_method’ => ‘diff’,
    ‘ex_posts’ => ”,
    ‘before’ => ”,
    ‘after’ => ”,
    ‘num_results’ => 1,
    ‘echo’ => true
    ));?>

    Do you have an idea where the glitch is? At the moment, it is too fragile to use.

    Many thanks
    Neil

  158. Piet says:

    Fantastic plugin! Does what it says it does and fully customizable. Thanks so much!

  159. ambrosite says:

    @Neil I have no idea why you would be getting a database connection error. I have never seen that error before, and no one else has reported it either. If you want more help with this, send me an email and maybe we can work through some troubleshooting steps specific to your problem.

  160. Neil Stoker says:

    @ambrosite – that helps to know, and further investigation suggests it’s a server issue, and nothing to do with your plugin, sp apologies and thanks. Just never had that database connection error before in an intermittent way in an established site. Onwards and upwards!

  161. herb says:

    @ambrosite, im using a custom template page which are displaying post from a certain category and all is well with the default nav. im wanting the ability to browse the first and last post in addition to previous and next. this is the code that ive place in my template page..

    true,
    ‘in_same_cat’ => true,
    ‘order_by’ => ‘menu_order’,
    ‘order_2nd’ => ‘post_date’,
    ) ); ?>

    true,
    ‘in_same_cat’ => true,
    ‘order_by’ => ‘menu_order’,
    ‘order_2nd’ => ‘post_date’,
    ) ); ?>

    the code does attempt to produce a previous and next link, however it seems to not browse the individual post, when I hit either button it just refreshes the image basicly. ive tried to also post this same code in the single.php file but am getting the same results. ive also added and removed the 1st and 2nd order_by perameters. is there something im missing. thanks.

    im using a child theme over wp2010

  162. herb says:

    hey, my previous code appears to have been stripped out, its basically missing the php tags and that the end posts where set to true.

  163. CHris says:

    This seems to be a awesome plugin with loads of features but unfortunately it doesn’t have an settings page… Can’t go through all that PHP myself…

  164. ambrosite says:

    @Chris I have thought about adding a settings page, but it won’t be ready in time for the next version of the plugin. Maybe for version 3.0.

  165. mark says:

    Is it possible to format %date to show Month Year instead of Month Day, Year? (ex: July 2011 instead of July 1, 2011)

    Tried changing line 256 to show ‘F Y’ instead of ‘date_format’ but that caused the date text to go missing. . .

  166. mark says:

    I was close. . .
    I had tried:
    $date = mysql2date(get_option(‘F Y’), $post->post_date);

    Line 256 should be:
    $date = mysql2date(‘F Y’, $post->post_date);

    to accomplish this

  167. ambrosite says:

    @mark Thanks for the update. I am getting ready to release a new version of the plugin; I will see about adding the option to format the date.

  168. Doddy says:

    amazing plugin.. thx u

  169. Yves says:

    Merci beaucoup pour cet excellent plugin !

    It is exactly what I was looking for !

    Bravo pour ce travail parfait !
    Bien amicalement,Yves

  170. Oscar says:

    Hi!

    Great plugin! Working on a e-commerce project and needed a good way to navigate through products since the plugin doesn’t come with support for that.

    However, for some reason it outputs a 1 (one) after the link outside the and

    Like this:
    « Post_Title1<a hre…

    Thanks!

  171. ambrosite says:

    @Oscar I cannot tell what the problem is, based on what you posted, however if you give me a link to your site I will take a closer look.

  172. Sarah says:

    Your plugin is amazing. I have a custom post type of ‘projects’ and then four custom taxonomies which are sub-categories of that post type. Your plugin allows me to cycle through every post in each taxonomy and it works great for the portfolio site I am building.

    Do you have any ideas on how I could add a link on the last post in the first taxonomy to the next post in the next taxonomy?

    This functionality would allow users to have two kinds of navigation: the first would allow users to tab through different sub-categories of projects and see those posts and the second would allow a user to just click through all projects in all the categories from the next post link.

  173. ambrosite says:

    @Sarah It might be possible but I need more information. If you give me the link to the portfolio site, as well as the parameters you are currently using with the plugin, I’ll take a closer look.

  174. arkante says:

    Hi,

    I also get a trailing one after the link. 1.

    Any idea why? I trying to find the bug without success…

  175. Steven says:

    How would I get this to work with the Post Types Order plugin? You say it’s now compatible but the following still does match the order of my custom posts using the Post Types Order plugin:

    ‘%link’,

    ‘link’ => ‘Previous’,

    ) );?>

    Which variables would I use for this to work?

    Many thanks

  176. Hi J. Michael:

    Thanks for providing such a great plugin! I’m currently using it on a gallery site on which I started using BR tags to style longer titles. This resulted in BRs showing up in the next/previous links so I added some code into the template to strip out the BRs.

    However, my ham-handed coding now results in the max_amount values being off when it counts “” and some titles don’t show the “…” any more. Can you provide any ideas on how to correct these issues, and perhaps include these concerns in future versions? Thanks so much!!

    And here’s a link to that displays the missing “…” (see previous link to “Haley Hasler Profile in”)

    http://www.rjdgallery.com/news/gallery-artist-in-nytimes/

  177. My code for BR above got stripped out. Here’s what I meant:

    …However, my ham-handed coding now results in the max_amount values being off when it counts “<br />”…

  178. ambrosite says:

    To the people reporting a trailing ’1′ after the link: you need to give me your website URL. I’ve never seen this problem before, but if I can see it happening I might be able to figure it out.

  179. ambrosite says:

    @Steven The Post Types Order plugin stores the sort order in the menu_order field, so you need to set menu_order as the primary sort column using the order_by parameter:

    ‘order_by’ => ‘menu_order’

    (Perhaps I should put that in the FAQ.)

  180. ambrosite says:

    @Zoinks The ‘…’ are not displaying on that particular link because they are being inserted inside the ‘br’ tag. That is, because you are using the XHTML style self-closing tag, there is a space inside the tag, and that is where the ‘…’ is being inserted (you can see this for yourself if you view source on the page). The easiest workaround would be to use the HTML5 style tag instead, which does not require self-closure, and therefore does not contain a space: <br>

    As far as the counts being off, I don’t know of any way to fix that without writing regular expressions to find and strip out the tags before the title is truncated. Frankly, I think this is enough of an edge case that such a change is not warranted (I’ve never heard of anyone inserting line breaks in post titles before now).

  181. @ambrosite Thanks so much for looking into this so quickly! A few followups…

    Your suggestion to look into the source code for ‘…’ not displaying was dead-on! However, since I tend towards XHTML coding, I added these lines of code to get the ‘…’ to show correctly:

    $PrevPostLink = str_replace(‘<br…’,'…’,$PrevPostLink);
    $PrevPostLink = str_replace(‘ …’,'…’,$PrevPostLink);

    $NextPostLink = str_replace(‘<br…’,'…’,$NextPostLink);
    $NextPostLink = str_replace(‘ …’,'…’,$NextPostLink);

    As for people inserting line breaks in post titles constituting an “edge case”… Respectfully, that may have been true back in the day when WordPress was *just* being used for blogging. However, now that it’s being used more and more as a CMS, I see this changing in a big way. I myself have had a number of clients ask “Can you just bump that word to the next line?” in regards to titles. Since previously WordPress had stripped out all HTML, this was not an option. It was only recently on a whim that I tried putting in the BR using WP 3.2.1 and it worked, so I’m guessing the WP folks see this trend increasing as well. I can further expand my function in the theme to account for “if includes BR, add X number of letters to the call” but I figured I’d let you as the developer know about future-proofing the script to account for HTML before it gets to the theme. I’d be happy to lend my expertise, such as it is! I really think once people realize they can add HTML to titles in WP 3+ this will be less of a fringe issue. :)

    And finally, is there a way to subscribe to this comment thread so I can get an email when a response has been posted?

  182. arkante says:

    Hey, I can’t give an url as it is local development. But the next post link plus generate the following html:

    Link1

  183. ambrosite says:

    @arkante I have no idea what is causing it. Can you tell me what parameters you are using?

  184. ambrosite says:

    @Zoinks Thanks for your additional feedback. I just released a new version of the plugin a few days ago, and I don’t plan to update it again until after WP 3.3 comes out, so for now I am going to sit on your suggestion and wait to see whether anyone else requests something similar. In the meantime, you can add the following code above line 269 of the plugin file (version 2.3); it will take care of both problems you are having, and save you all the rest of that code you are putting in your templates:

    $title = str_replace( '<br />', '', $title );

    You can subscribe to the comment feed for this post if you want to be notified of new comments:
    http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress/feed

  185. arkante says:

    I tried to debug it myself but couldn’t find the problem.

    Here is my config:
    ‘loop’ => ‘true’
    ‘post_type’ => ‘”realisation”‘
    ‘format’ => ‘%link’
    ‘link’ => ‘%title’

  186. arkante says:

    There were span tags in the ‘link’ config.

  187. ambrosite says:

    @arkante The only thing that would cause the link to be wrapped in span tags is if you are trying to display the post thumbnail (‘thumb’ => true), but you’re not, so that can’t be the explanation.

    I cannot find anything in the code that would cause a ’1′ to be inserted in that spot. If you ever get your site uploaded to a server where I can see it, I’ll take a closer look.

  188. ambrosite says:

    I have a theory about the trailing ’1′s. Are you trying to echo the output of next_post_link_plus, like this?

    echo next_post_link_plus();

    You don’t need to do that. The function echoes the link to the screen before it returns. The return value of the function is either Boolean true or false, depending on whether a next/previous link was found. When a Boolean ‘true’ is echoed to the screen, it is printed as ’1′. So just get rid of the unnecessary echo, and the problem will be solved.

  189. Pete says:

    Hi,
    I’m having a problem using this plugin with custom post types and the WPML plugin.
    I have set up a sets of custom post types, for example: case studies, staff members etc and they display as single custom posts ok.. but i want to use the next / previous post link plus plugin to display next and previous links for the custom post types (sorted by a custom field from the dashboard)

    In a previous version this was functioning ok and i had no problems..
    I have recently been updating my theme and plugin files and now when i view
    these custom post types ( for example: the case studies single post view page >> http://www.rcs-advertising.com/?cstdy=state-street

    then the links to the next and previous posts are displayed in the wrong language and link to the japanese page instead of the english page.

    If i view the same page in Japanese mode this problem is reversed.

    Is this some issue with the plugin? or my setup of WPML?
    have you seen this happen before?

    and could you give me some advice about how to go about fixing it.

    Thanks for any help! wordpress has been giving me headaches all weekend!

  190. ambrosite says:

    @Pete I have not seen this problem before. First, may I ask you to try downgrading to version 2.2 of the plugin and see whether that solves the problem? You can download it here:

    http://www.ambrosite.com/download/ambrosite-post-link-plus.2.2.zip

    The only thing I changed in version 2.3 that might cause this was the addition of the post_type parameter. But unless you are trying to get posts from multiple post types to appear in the next/previous links, you should omit this parameter and let it default to the current post type. That is how it worked in version 2.2.

  191. Soroush says:

    Hi,
    Thanks for this useful plugin.
    One bug/feature I wanted to report is that if you specify meta_key and use custom for order_2nd, the %meta won’t be replaced by the meta value. The fix is to change line 297 to:

    if ( ($r['order_2nd'] == ‘custom’ || $r['order_by'] == ‘custom’) && !empty($r['meta_key']) ) {

    Cheers

  192. @ambrosite Thanks for the suggestion about where to edit your plugin code. That sure makes sense, except… if you decide not to incorporate HTML-stripping in the new version… the hack will go away and the display will go back to being messed up when I upgrade the plugin. And since you’re calling it a fringe issue, that scenario seems kinda likely. So for now I’ll keep my edits in the theme. Thanks again for your hard work!

  193. Piet says:

    @ambrosite, I am experiencing a similar problem as @Pete does above.
    I am also using a Custom Post Type and WPML. English is the defult language and Dutch is the 2nd language.

    Previously, with version 2.2, the prev/next links worked perfect on the default language, but not at all on the 2nd language (there was nothing there).

    Now on the 2.3 version of your plugin, the prev/next links actually do show up on the 2nd language, but the links go to the English content. For the English version nothing has changed, so still works.

    I already have tried to replace ‘in_same_tax’ => true with ‘post_type’ => ‘name-cpt’, but that resulted in the prev/next links disappearing from the Dutch version again.

    Also leaving in_same_tax in combination with post_type has not the desired result.

    How can this problem be solved?

    Thanks for any input!
    Piet

  194. ambrosite says:

    @Soroush Thanks for the note, however your fix will not work the way you intend. Look at lines 44-50 of the plugin file — ‘custom’ is not a valid value for the order_2nd parameter, and if you set order_2nd to ‘custom’, it defaults to ‘post_date’ instead. The purpose of the secondary sort column is simply to provide a backup in case the values in the primary sort column are not unique. If you are creating custom fields to sort your posts, you should use ‘custom’ as the primary sort column, and leave post_date or post_title as the secondary sort column.

  195. ambrosite says:

    @Piet Unfortunately I have no idea what is causing the problem, and since WPML is a commercial plugin, I cannot even download a copy of it to test. Since my plugin works correctly with WordPress core, since WPML is charging for their plugin, and since they claim “Every new release of WPML includes better interoperability with popular plugins” on their website, I would say the onus is on them to fix this problem.

    Nevertheless, I will contact them and ask them to issue me a developer’s subscription to WPML. If I can get a copy of WPML to test, and if I can determine the cause of the problem, I will release a fix.

  196. Piet says:

    @ambrosite, thanks for your reply. OK I understand what you mean. Talk to Amir Helzer of WPML, he usually is very enthusiastic when other plugin developers want to cooperate and have plugin interoperability!

  197. ambrosite says:

    @Piet Thanks for giving me Amir’s name. I submitted an official request for a developer’s subscription through WPML’s Go-Global program earlier today, so I will wait a few days and see if I get a reply. Otherwise, I will try contacting Amir directly.

  198. Piet says:

    @ambrosite you have my email address. If you pop me an email, I can give you Amir’s and Mihai’s direct email addresses.

  199. voxoff says:

    @ambrosite – hi, i have one question:

    i usually use your plug-in this way:
    $adjacent_post_next = get_adjacent_post_plus(array(‘loop’ => true,’in_same_cat’ => false,’in_same_tax’ => false),true);

    and then a need the ID of the adjacent post:
    ID; ?>

    with the new version i can´t get this to work :(

    how can i get the next post ID with your new syntax?
    thnks

  200. voxoff says:

    @ambrosite – sorry the comments cut the code

    and then a need the ID of the adjacent post:
    echo $adjacent_post_next[0]->ID;

  201. Damon Tribble says:

    Thanks for your work on this plugin. I’m wondering if it will work for my situation or if there’s a workaround you can suggest.

    I have a taxonomy called “industry” on a portfolio site I’m building. Under that taxonomy, there are categories such as branding, packaging, identity, etc. I would like to make it so when someone views a post in the branding category (under the “industry” taxonomy) the previous and next links only show them other projects in the branding category. Is this possible to do with your plugin? Each portfolio item can have several categories in the “industry” taxonomy so you can see my issue. So far, I have been able to get it to display all posts in the “industry” taxonomy but have been unable to restrict it to a certain category under that taxonomy. Thanks for any help you can offer.

    -Damon

  202. ambrosite says:

    @voxoff My code is really not meant to be used that way; it will generate a lot of “undefined variable” notices (and potentially cause unpredictable behavior) since you are bypassing the default parameter initialization that takes place in adjacent_post_link_plus. That said, I did not make any changes in the latest version that would stop your hack from working. Are you sure the function is finding a next post? Try dumping the contents of $adjacent_post_next to make sure it contains a post object:

    var_dump($adjacent_post_next);

  203. ambrosite says:

    @Damon Use the in_same_tax parameter, and pass the name of your custom taxonomy, like this:

    ‘in_same_tax’ => ‘industry’

    That will restrict the next/previous links to the ‘industry’ taxonomy only. As far as restricting it to specific taxonomy terms, you could try using the ex_cats parameter (which should probably be called ex_terms, since it works with custom taxonomy terms as well). Put the IDs of the terms you don’t want to be displayed in ex_cats, and set ex_cats_method to ‘diff’. Check the FAQ (2nd question) for a further discussion.

  204. Andreas says:

    Hi, this is an extremely useful Plug-In. Congratulations. I would like to use the “in_same_cat”-feature — but to include posts that are in different categories with the same parent category. Is it possible to use the Plugin-In this way, that is something like “in_same_parentcat”?

  205. ambrosite says:

    @Andreas The way the plugin is coded now, there is no direct way of doing that. However, you could do it indirectly by leaving in_same_cat false, then excluding all categories except the ones you want using ex_cats, and setting ex_cats_method to “diff”.

  206. David says:

    Terrific plugin.

    I am having an issue displaying the ‘next post’ link. For some reason unless I include ‘num_results’ => 2, (which I don’t want) it just doesn’t display. All I get is the text linked to the post. No thumbnail.

    An idea?

    Thanks

  207. David says:

    My mistake. Client had removed the featured images from several posts, which gives me a feature idea: it would useful to be able to draw the thumbnail from the body of the post and set a default thumb; much like Justin Tadlock’s Get The Image plugin does.

  208. Laura says:

    I’ve put the “complete sample” code in my Graphene child theme loop-single.php page (nothing else is there).
    The new links show up at the top but the post content itself doesn’t.
    http://juicytravels.com/the-ten-best-airline-experiences-now-4/
    In fact, everything after the links down to the footer is gone.
    What have I done wrong?

    Thanks

  209. ambrosite says:

    @Laura My guess is, you’ve omitted a closing brace somewhere that is causing the rest of the code to be skipped. I would need to see the entire template file in order to tell you exactly what to fix. You can email it to me if you want, and I’ll take a closer look.

  210. Jonathon says:

    Really liking the plugin, but I hit a snag…

    I’m trying to use this to generate previous / next links to navigate posts loaded inside of a lightbox (Facebox) displaying a simplified post template.

    The links display and function fine, but when clicking on them, it closes the lightbox and loads that simplified post in the main browser. Any clue how to instruct it to remain inside of the opened lightbox? Possibly a way of adding rel=”facebox” somehow to the previous / next links?

    Thanks for your thoughts.

  211. ambrosite says:

    @Jonathon What you are asking is impossible, or at least very difficult. A lightbox is a JavaScript effect. My plugin does not use JavaScript, and adding rel=”facebox” to the links will not solve the problem. The plugin would have to be completely rewritten to make it compatible with a lightbox, and even then there is no generalized solution; every brand of lightbox works a little differently, and I would have to write special code for each one.

  212. Jonathon says:

    @ambrosite I completely understand, I appreciate the feedback. It’s one of those client requests that seem more simple than they really are ;)

    Thanks again for the plugin, it’s a great improvement to the stock nav.

  213. Derek Haines says:

    Great plug in and working beautifully. Just one small modification I would like to do but can’t find a way. I would simply like to centre the prev-next links above the post. Currently it is all left aligned. I’m using the Graphene theme. Any help greatly appreciated.

  214. Ian says:

    Thanks for the plug in.

    I am usingthe Gridlocked wp theme and have installed your plug in to cyhange the way the next and previous buttons work when viewing a certain skill type. Technically it works fine, however originally there where tao buttons with aroow inside them and after i installed the plugin the arrows in the buttons have gone and there are two diffreent arrows outside of the buttons.

    I would like the original arrows left in the buttons. Are you able to help?

    This is how the code looked before i altered it:

    <?php next_post_link(__('%link', 'framework'), '%title’) ?>

    <a href="”>

    <?php previous_post_link(__('%link', 'framework'), '%title’) ?>

    And after:

    true))?>

    <a href="”>

    true))?>

    You can see an example of a page here:

    http://www.youngstardesign.co.uk/wordpress/?portfolio=seychelles-t-shirts

    Many thanks

  215. Ian says:

    This is the code after i altered it:

    true))?>

    <a href="”>

    true))?>

    Thanks

  216. Joe says:

    I owe you a big thanks for putting this one out there. You saved me a ton of work!

  217. ambrosite says:

    @Ian According to the “before” code you posted, you would need to set the format parameter as follows:

    ‘format’ => __(‘%link’, ‘framework’)

  218. ambrosite says:

    @Joe Thanks for the positive feedback! It is a big help in keeping me motivated to continue developing the plugin.

  219. Rob says:

    Awesome plugin! The only thing I’m missing is the option to add stuff to the href itself. For example, I’d like to add a ‘?template=clean’ to the link if the current post fits certain conditions.

  220. Rob says:

    Or the option to ONLY return the href, not the entire html tag…

  221. Rob says:

    Hmm, I guess that wasn’t the only think I was missing… :)

    Another request: I have posts that are tied to both a category and a custom taxonomy. I would like to fetch links only to posts fitting BOTH taxonomies; That is, for example, posts that are in the category ‘news’ AND with the custom taxonony term ‘Sweden’. Seems like the query fetches rows with EITHER term ID. Is this possible?

  222. ambrosite says:

    @Rob The option to return only the href is an easy enough fix; I will consider adding that in the next version of the plugin. As for your second request, that would require a change to the underlying SQL query. Such a change would fundamentally alter the operation of the plugin and create backward compatibility problems, however if you wanted to hack the plugin code, you could try this (replace lines 107 through 109):

    ** Code removed because I realized it won’t work. I’ll have to think more about whether your request is possible.

  223. Rob says:

    Thanks a lot for the answers! I realize it isn’t easy. I managed to get it working by using in_same_tax (with the custom taxonomy) and ex_cats (strong), where ex_cats would exclude all categories except the one of the current post. Looking at the sql I realize this won’t work in the long run though, since it fetches a whooole lot of post Ids…
    Maybe you could inner join the tax table twice, once for category and once for custom tax?

  224. Ranjan says:

    Hi, Your plugin solved my biggest headache. i didn’t want the prev/next to jump to another portfolio category just because they were posted on random dates. Thanks for the life-saver.
    I HAVE ONE QUERY. How do we make the prev/next links display as the original rather than the post name with this plugin. Thanks

  225. ambrosite says:

    @Ranjan I do not entirely understand what you are asking, but in general, you can control the appearance of the links using the ‘format’ and ‘link’ parameters.

  226. Paul says:

    Great Plugin!!! I’m using it with The Post Types Order plugin and works a treat!!!

    One question…. I’m using it on a catelogue site. Custom post types and custom taxonomies.

    Is there a way to display …

    “post order number” of “total posts”

    eg … “5 of 12 items”, “6 of 12 items” etc…

    Sorry if this is a little off topic… just very stuck!!!

  227. ambrosite says:

    @Paul It may be possible, but it would require a change to the underlying SQL query, so it is not a trivial fix. I’ll look into adding that feature in the next version of the plugin.

  228. Great work and great plug-in. Is there a way to limit where the entire next/previous appears. Meaning there is a category and posts that I don’t want any option of next/previous post to work. I know how to limit the other categories in appearing in the next/previous but I want the whole thing to not display on some posts/categories. Any ideas?

  229. ambrosite says:

    @Christopher You could set the ‘echo’ parameter to false (so the function returns the link as a PHP string). Then use the ‘in_category’ function to check the category of the current post, and echo the next/previous links only if it is in (or not in) the specified categories:

    http://codex.wordpress.org/Function_Reference/in_category

  230. Christopher says:

    Ok thanks for giving me the tools to make it happen. GREAT SUPPORT! Will try my best here. Appreciate your hel.

  231. ambrosite says:

    @Rob I have been thinking more about your question. It is possible to do what you ask using a correlated subquery. Correlated subqueries are an advanced SQL topic, and a lot of SQL books gloss over them, but they are exactly what is needed here. I have provided a sample SQL statement below. Basically it is running the same query twice, once for the category and once for the custom taxonomy. The two queries are related to each other through the clause ‘WHERE p.ID = p2.ID’. The fact that the inner query contains a reference to a column in the outer query is what makes it a correlated subquery (as opposed to a simple non-correlated subquery). ‘EXISTS’ is a special operator that checks to see whether the subquery returns any rows. It’s a bit tricky, but hopefully by examining the sample code you will be able to grasp what it is doing.

    SELECT DISTINCT p.* FROM wp_posts AS p
    INNER JOIN wp_term_relationships AS tr ON p.ID = tr.object_id
    INNER JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
    WHERE p.post_title > "Current Post"
    AND tt.taxonomy = "category"
    AND tt.term_id = 3
    AND EXISTS ( SELECT * FROM wp_posts AS p2
    INNER JOIN wp_term_relationships AS tr2 ON p2.ID = tr2.object_id
    INNER JOIN wp_term_taxonomy tt2 ON tr2.term_taxonomy_id = tt2.term_taxonomy_id
    WHERE p.ID = p2.ID
    AND tt2.taxonomy = "my_custom_taxonomy"
    AND tt2.term_id = 5 )
    ORDER BY p.post_title ASC

  232. Ranjan says:

    Ranjan says:
    October 2, 2011 at 7:24 am

    Hi, Your plugin solved my biggest headache. i didn’t want the prev/next to jump to another portfolio category just because they were posted on random dates. Thanks for the life-saver.
    I HAVE ONE QUERY. How do we make the prev/next links display as the original rather than the post name with this plugin. Thanks
    ambrosite says:
    October 4, 2011 at 9:51 am

    @Ranjan I do not entirely understand what you are asking, but in general, you can control the appearance of the links using the ‘format’ and ‘link’ parameters.

    ————-

    Hi,

    I mean to say
    Display Prev/Next as « Prev/Next » (which is what i want)

    Right now, it is at « %postname%/%postname% »

  233. Chris says:

    Great plugin and it works!

    I do have a question, i got a meta_key which is a checkbox and it’s called has_case_study. Is there a way to display the next and prev link just the posts that has the checkbox checked or on?

    Thanks in advance,
    chris

  234. ambrosite says:

    @Chris It sounds like you are basically asking for an ‘in_same_meta’ parameter? That might be possible but it would require a code change. I will consider adding that feature in the next version of the plugin.

  235. Chris says:

    thanks for the fast reply, is there a hack for your plugin to just check if that custom field checkbox is checked and display just those posts?

    thanks so much.

  236. ambrosite says:

    @Chris I haven’t looked into it yet, but I know it requires a change to the underlying SQL query, so it is not a trivial fix. I’ll be updating the plugin after WordPress 3.3 is released, probably around mid-December.

  237. Chris Hocking says:

    I’m sure this has been asked before – but I couldn’t find the answer here (or maybe I’m just being stupid).

    Is there a way to do the opposite of “ex_cats”?

    I want to ONLY include posts that have specific taxonomy value. Possible?

    Thanks for an amazing plugin!

  238. ambrosite says:

    @Chris Yes, it has been asked many times before. At the moment there is no way to do this, however by popular demand I am planning to add an ‘in_cats’ parameter to the next version of the plugin. The new version should be out shortly after WP 3.3 is released.

  239. Julian says:

    Is it possible to only select posts that match a specific meta_value in the next and previous links. E.g. I have a ‘Category’ meta variable that I use as the Main Category. I only want the links to link with other posts within the category meta variable.

  240. Andy says:

    Hello,

    I needed to be able to add extra query string variables to the links generated by the plugin so i added some code and thought i’d share it.

    I added

    , ‘query_string’ => ”

    to line 238, adding a new param to the defaults.

    I then replaced the two instances of get_permalink($post) (line 289 & 323) with get_permalink($post).$r['query_string']

    I am now able to add custom get params to the links. Because it simply concatenating it is up to the developer to choose whether to use ?key=val or &key=val if there are already get params.

    Thought you’d like to know.

    :-)

  241. ambrosite says:

    @Julian I am planning to add an in_same_meta parameter to the plugin in the next version. It should be out shortly after WP 3.3 is officially released.

  242. ambrosite says:

    @Andy Thanks for sharing your solution. I am sure some people will find it useful.

  243. Julian says:

    @mbrosite Thanks for the quick response. The hack I used will just have to hold until the next version is release.

  244. Julie says:

    Hi. I am using the Thesis theme and would like to use this plugin. Where do I need to add this code? There is no single.php in Thesis.

  245. ambrosite says:

    @Julie You need to ask this question on the Thesis support forum. I cannot give specific instructions for every theme since they are all different, and in the case of Thesis I cannot even view the code because I do not own a license.

  246. Zoran says:

    Hi.

    First of all, thank you for the plugin. Now a question: Is there a way for your plugin to work in synergy with timthumb plugin? Like, for instance, yarrp plugin (related post). You can see the example on my site: http://www.zoran-art.com/2011/blog/home/

    Is there a way to pull out timthumb thumbs instead of wp thumbs?

    Thanks in advance and a happy New Year!

  247. Zoran says:

    Also, is there a way to have a tooltip with image on mouse-over? You can see how that would be beneficial for my website – I already have four related post images and two more thumbnails would, probably, be a visuall overkill… But not if you could show next/prev images as a tooltip, only on mouse over.

    I’ve been searching various tooltip plugins ans although I have the knowledge to implement those on fixed links, I don’t know how to do it with dinamically generated links. I don’t even know if it’s possible so, forgive my ignorance if I’m asking for something unrealistic :)

    Thanks again and all the best!

  248. ambrosite says:

    @Zoran Your request is technically possible, but it is not a trivial project — it would require a substantial rewrite of the plugin code. I have no plans to add that feature to the plugin, however if it is important enough to you to invest in custom programming, I am available for hire. Please contact me via email if you want to discuss further.

  249. Zoran says:

    Thank you for the reply. It’s not that important. It’s just that your plugin is full of (great) features that I don’t need, and the only one that I actually need is not available :)

    Thanks again and best wishes.

  250. Dan says:

    I am amazed at how the authors of these useful tools are often so clueless about the human race and their target demographic. Presumably you hope for average WordPress users to be able to use your great and wonderful tool, but you fail to provide a simple “Here is How to Use it” note anywhere. You presume the world should be up to speed with what you have spent years of your life coming up to speed with. A simple walk-through of where to find the file and what exactly needs to be changed or added and exactly where it needs to be added would increase your user base 100 times over. It would only take 5 to 10 minutes of your time to write something that would make it usable to the majority of people who now simply have to walk away. What a waste of your effort to work so hard on something that is not used by so many people who want to use it. Do you really lack the talent and empathy to figure out how to explain the simple installation of the code? Is it that hard for you to do something so basic and so critical to success? How sad.

  251. ambrosite says:

    @Dan When you say “the authors of these useful tools are often so clueless,” are you referring only to me, or are you angry at other people too? lol

    In the first line of the plugin description, I wrote “this plugin creates two new template tags.” That is what my plugin is: a pair of template tags, just two out of the hundreds that are included with WordPress:

    http://codex.wordpress.org/Template_Tags

    In order to use template tags, some basic knowledge is assumed on the part of the user — specifically, that you know what template tags are, that you know how to edit your templates, and that you know a little bit about PHP scripting. That is the minimum level of technical knowledge you must have in order to use any of the template tags that are part of WordPress. They are not intended for use by absolute beginners, however anyone who is willing to invest some time in reading the WordPress Codex can learn how to do it.

    You want me to write “a simple walk-through of where to find the file and what exactly needs to be changed.” As I have explained at least a half dozen times in these comments, that is impossible because the exact details of what needs to be changed are different in every theme. I would have to write separate walk-throughs for every single one of the thousands of WordPress themes out there. As it is, I have already spent many hours writing extensive documentation on how to configure the plugin, including numerous examples. The vast majority of people who have contacted me about the plugin have no trouble following the documentation and using the example code. I do what I can to help people who have questions, however I am not inclined to go out of my way to assist someone who approaches me with a rude and condescending attitude. I think you will find that most plugin authors feel the same way.

  252. Hi,
    Is there a way to return the next post ID, using

    next_post_link_plus( array(‘end_post’ => ‘fixed’,'format’ => ‘%link’,'link’ => $image, ‘loop’ => true) );

    I have tried :
    $adjacent_post = get_adjacent_post(false,”,false) ;
    $my_next_post_ID = $adjacent_post->ID;

    But it the last post ID – 1…
    Any idea ? Thanks by advance !

  253. Dan says:

    My charge does not only apply to you and was a general comment, but it still stands. I think software authors want these tools to be used, but by not addressing their application with a little empathy for the VAST majority of people who wish to use them, your work is not being utilized as I suspect you would like it to be.

    Having more people able to use and appreciate what you do would certainly bring more clients as well. Those people, the ones who are not programmers, are your target market.

    You do not see how cryptic your offering is because it is not cryptic to you. I am a designer/developer (non-programmer) and can figure things out because I have to and I have a smidgeon of familiarity with what is going on, but it is frustrating that a few more elementary clues are not in place to save me hassle and time. And from working with clients that know less than me, I KNOW there are countless people who simply turn away from your almost easy to use and very powerful tool.

    Good luck to you. Your efforts are appreciated, but I promise you that you are missing numerous opportunities to shine in the eyes of potential new clients.

  254. ambrosite says:

    @Dan Believe it or not, I do understand how you feel. I have felt similar frustrations myself while trying to use open source tools written by other programmers. In some cases, no documentation is provided whatsoever, and the programmer takes an openly hostile attitude toward people who ask reasonable questions. The documentation and support that I provide with my plugin is actually quite thorough compared to a lot of what is out there.

    The reality that you, and I, and everyone who uses open source tools must face, is this: Open source software is written by programmers, for programmers, and the people who benefit the most from open source are those who can read and understand the code for themselves. The programmers who create the tools do it because they love technology, and in the vast majority of cases they receive no compensation for their efforts apart from the personal satisfaction of having created something “cool”. Technical writing and customer support are entirely different skill sets from programming, and it is not surprising to me that many programmers either do them poorly, or choose not to do them at all.

    Frankly, I think WordPress and other open source projects do themselves a disservice by constantly proclaiming that their software is easy to install, easy to use, etc. which creates a false expectation among non-technical users. If all you want to do is install WordPress in its basic configuration, and use a pre-built theme from the theme directory, then yes, it is fairly easy. However as soon as you start trying to customize things, you will find that there is no way to do it without editing the code, and at that point you must either learn programming yourself, or you must hire a programmer to do it for you. Given the way WordPress is architected, I really don’t see that ever changing.

  255. ambrosite says:

    @mecanographik You are the second person to request the option to return the post ID, so I will add that feature in the next version of the plugin, which I plan to release by early February at the latest.

  256. junglerat8 says:

    Great plugin, thanks!

    I can’t seem to get the code for inactive links to work:

    <?php if ( !previous_post_link_plus() ) {
    echo '« Previous’;
    } ?>

    The rest of my code looks like this:

    ‘menu_order’,
    ‘order_2nd’ => ‘post_title’,
    ‘meta_key’ => ”,
    ‘loop’ => false,
    ‘end_page’ => false,
    ‘thumb’ => false,
    ‘max_length’ => 0,
    ‘format’ => ‘< %link’,
    ‘link’ => ‘Previous’,
    ‘tooltip’ => ‘%title’,
    ‘in_same_parent’ => true,
    ‘in_same_author’ => false,
    ‘ex_pages’ => ”,
    ‘in_pages’ => ”,
    ‘before’ => ”,
    ‘after’ => ‘ |’,
    ‘num_results’ => 1,
    ‘echo’ => true
    ) ); ?>

    Plus the same code for the next link. I’m just placing that inactive code after this code, and what ends up happening is that the full link and title show up next to the Next/Previous links. Am I missing something? Thanks for all your quick replies on this thread too! Great support!

  257. junglerat8 says:

    Hmmm, it stripped it out for some reason, but above ‘menu_order’, I also have

    before ‘menu_order’.

  258. ambrosite says:

    @junglerat8 I cannot tell, from the code you posted, what the problem might be. If you want to send me your template file as an email attachment, I’ll take a closer look.

  259. Christina says:

    I just wanted to thank you for this amazing plugin. It’s extremely flexible and does exactly what I need. I’m by no means an expert php coder, so I found your documentation useful! Best regards to you!

  260. ambrosite says:

    @Christina Thank you, I appreciate that very much. :)

  261. Patrick says:

    Hi ambrosite. TY for the plugin. It is working as advertised, and I appreciate the contribution you’ve made to the WordPress community. Here is my question:

    I have a hierarchical custom post type (Chapters), and I use the plug-in called Simple Page Ordering to help re-order my posts. Simple Page Ordering works just like other page ordering plugins that you mention in the documentation.

    Let’s say that I have several chapters in a hierarchical structure, where some “parent” chapters have “children” chapters. The problem is that menu_order is set depending on the hierarchical level, like so:

    * Chapter 1 (menu_order == 0)
    * Chapter 1.1 (menu_order == 0)
    * Chapter 1.2 (menu_order == 1)
    * Chapter 1.3 (menu_order == 2)
    * Chapter 1.4 (menu_order == 3)
    * Chapter 2 (menu_order == 1)
    * Chapter 2.1 (menu_order == 0)
    * Chapter 3 (menu_order == 2)
    * Chapter 4 (menu_order == 3)
    * Chapter 4.1 (menu_order == 0)

    In order for next_post_link_plus to work the way I want, the menu_order needs to ignore hierarchy. Everything would work fine if Simple Page Ordering set menu_order like so:

    * Chapter 1 (menu_order == 0)
    * Chapter 1.1 (menu_order == 1)
    * Chapter 1.2 (menu_order == 2)
    * Chapter 1.3 (menu_order == 3)
    * Chapter 1.4 (menu_order == 4)
    * Chapter 2 (menu_order == 5)
    * Chapter 2.1 (menu_order == 6)
    * Chapter 3 (menu_order == 7)
    * Chapter 4 (menu_order == 8)
    * Chapter 4.1 (menu_order == 9)

    …But that’s not how it works, and as far as I can tell the other page ordering plugins set menu_order in the same way.

    So, this is not a problem with your plugin at all and you may be unable to help, but I’m wondering if you might have any suggestions on how to solve the problem short of manually setting menu_order.

    TY,
    -Patrick

  262. ambrosite says:

    @Patrick First, I would suggest that the Simple Page Ordering plugin is doing it wrong. If posts are to be sorted on menu_order, then every post should have a unique value in that field. Otherwise it is like giving two posts the exact same title and then trying to sort on title; obviously there is going to be a problem. I would be interested to hear their reasoning for doing it the way they did.

    I would also ask, do you really need a hierarchical structure for the book chapters? You might say, “it is supposed to be like an outline,” but an outline is primarily an organizational tool for writers. Most printed books are laid out in a purely linear format — page 1 to page 200, with every chapter and subsection on the same “level”, and read sequentially. I don’t really see any navigational benefit to having the chapters in a hierarchy, especially considering some chapters have subsections and some don’t, which makes the hierarchical organization inconsistent and potentially confusing.

  263. Alex says:

    very useful and easy to use plugin. I’ve modified the code to include a ‘class’ option which I use for adding CSS classes to make the links look like buttons. Would you consider adding this to future versions?

    `
    $class = $r['class'];
    $anchor = ‘‘;
    `

  264. Alex says:

    hopefully this code looks nicer.

    $class = $r['class'];
    $anchor = '<a href="'.get_permalink($post).'" class="'.$class.'" rel="'.$rel.'"'.$tooltip.'>';$tooltip.’>’;

  265. Patrick says:

    @ambrosite Thank you for the quick & thoughtful reply! You’re a mensch. As for your first point, I totally agree. I’m not sure why they did it that way.

    As for your second point, I agree that the outline-structure is an organizational tool for me, the writer/site manager, and not something that affects the reader/user. The main benefit of the hierarchical structure is that if I drag-and-drop a parent chapter to a new location in my list of chapters, all the child chapters automatically follow it. This is a very helpful feature… but not worth messing up menu_order, I guess.

    Well okay. Thanks for responding. It helped to be able to bounce ideas off you. I’ll poke around a bit more for a post ordering plugin that preserves menu_order, or else I’ll just flatten out the chapter structure and ditch the hierarchy.

  266. ambrosite says:

    @Alex Someone else made the same request just yesterday. I added CSS classes to the new version of Page Link Plus which I released this morning, but unfortunately I did not get the suggestion in time for the Post Link Plus update. I’ll add them the next time I do an update, whenever that is (I don’t have a date set).

  267. ambrosite says:

    @Patrick Glad I could help. You might check out the Post Types Order plugin; I don’t know how it handles post hierarchies, but it seems to be very popular, and my plugin is compatible with it.

  268. Romain says:

    @ambrosite, First of all thanks for the nice plugin!
    I’m using it for a custom sort, with a meta key “event_date”, but some events have 2 meta values for this key (events running on more than one day have a beginning and ending date, and I can’t divide them in 2 keys as I already use event_date for other functionalities).

    In those cases, the next post link prints the current single post link (no differences if order_by is set to custom or numeric).

    Seems odd as your plugin is using a get_post_meta set on TRUE so it should only consider the first meta value.

    I’m guessing it has something to do with MySQL and $meta_join but I can’t quite put my finger on it. Do you have any suggestions?

    Thanks again for your work
    Cheers

  269. pendrive says:

    Hi, for some unknown reason I couldn’t get the “next” function working. It didn’t show the link. It works only if I have “next_post_link” then “echo” and then “next_post_link_plus”. In this configuration it works O_O I had to hide the link made by “next_post_link”. But I don’t see it as final solution.

  270. ZEESHAN says:

    thanks for such a wonderful plugin and support

  271. ambrosite says:

    @Romain It probably has something to do with the meta join returning two rows for that post, but I’d have to do some testing to be sure. I’ll take a closer look at it the next time I update the plugin.

  272. ambrosite says:

    @pendrive I don’t understand what you are asking. You would have to post your code if you want me to troubleshoot further.

  273. Elijah from Russia says:

    Do you know similar plugin for categories? I need to set next/previous category links on every category page.

  274. ambrosite says:

    @Elijah To my knowledge there is no such plugin, however I may consider writing one myself if I have time over the summer.

  275. stefan says:

    “Please note that in_same_meta is not compatible with custom field sorting. If order_by is set to either ‘custom’ or ‘numeric’, in_same_meta is disabled.”

    mhf. its a pity. would make so much sense if it could work. no chance? otherwise you have to replace one custom field with “category” or “post format”, dont you? anyway, great plugin!

  276. Jason says:

    Hi, First let me say thank you so much for this plugin – it’s really saved me!

    My question is, in my implementation of this, I have the thumbnail, title, and link all loading; but I’d like to be able to:

    a) Show a default image in the case where there is no thumbnail for that post
    b) Be able to wrap the post link around another element besides just the title. In this example, I’d like to have a styled button say ‘Prev Post’ right under the text link, but I’d need to wrap a link tag around the button. I put an image here as an example:
    http://postimage.org/image/mu0pr6759/

    Thank you in advance for any help you can provide!

  277. Edel says:

    Hi there! What an amazing plugin you have, I’m truly grateful for it. However, I too need some help with it. Unfortunately, I’m not that tech savvy.

    I use a custom post type (stories) and several custom taxonomies, one of them being “series”. Each series is one story. Also, each series contains chapters. Is there any way to navigate between the chapters of a single series/story without going in to the another series/story?

    I’m currently using the in_same_tax and setting it to true. I’ve also tried putting in “series” instead. Neither works.

    Any help is appreciated. Thank you for your time!

  278. Vesign says:

    Hi!

    I have a next link:

    true,’format’ => ‘%link’) ); ?>

    and the result is:

    http://www.vesign.se/nyaljus/

    Now i want to add #categoryslug, to the link, how do i do that?:
    http://www.vesign.se/nyaljus/#categoryslug

    I have this:

    slug; } ?>

    which gives me the category slug.

    /Vesign

  279. ben says:

    Is there a way for the posts to be displayed within a category(let’s say based on order of when each post was published) and once the last post in the category is displayed, then the post in the next category shows up, etc’

  280. Ryan says:

    Hi, Just wondering if I can use something like ‘in_same_tag’ for posts that are tagged the same. Obviously that function isn’t there, but can i access it somehow using the ‘in_same_meta’?

    Thanks!

  281. ambrosite says:

    @Ryan I have deliberately not supported in_same_tag because it would not work the way you expect. Once you hit a post that has more than one tag, the plugin will get confused and display next/previous links for all of the tags. Unfortunately there is no way around this. If you want to try it anyway and see for yourself, replace line 91 (in version 2.4):

    $taxonomies = array_filter( get_post_taxonomies($post->ID), “is_taxonomy_hierarchical” );

    With this:

    $taxonomies = get_post_taxonomies($post->ID);

    Then set the following parameter to force the plugin to use tags:

    ‘in_same_tax’ => ‘post_tag’

  282. Lucia says:

    Hi J. Michael,
    thanks for the plugin. Already rated it 5 stars!
    Just wanted to let you know that the patch to work with WPML works well.

  283. David says:

    I am using WP E-Commerce with this plugin because it’s the only thing that works. It’s doing exactly what I want except for one thing. It rotates through the main category instead of the immediate category. So if I have shirts -> band shirts -> black sabbath shirt, it rotates through shirts when I would like it to rotate through band shirts. Is there a way to drill down to that lat subcategory? Any help would be appreciated. Thanks.

  284. Trinzia says:

    Hi,
    I encountered an issue today while searching for the source of another bug. Anyway, if I install a theme in which I included the function previous_post_link_plus, but don’t have the plugin active, site dies.

    Could you please add to your examples a good IF clause to use so the theme can add support, whether or not plugin is installed?

    Thanks.

  285. ambrosite says:

    @David Are the “black sabbath shirts” also in the “shirts” category? That would cause the problem you are seeing. Any time you have a post in more than one category, the plugin will display links for all of the categories.

  286. ambrosite says:

    @Trinzia Please see the third question in the FAQ. The example you requested is there.

  287. lyndonr says:

    great plug-in. how can I inject my left/right arrows and extra text directly into the %link anchor?

    I’d like the entire “Next Article: Some Article Name →” to be clickable.

    thanks!

  288. Sammii says:

    Hi there,

    I am having troubles getting in_cats to function with my custom taxonomy terms. I desperately need my next/previous links to only navigate through the current taxonomy TERM. From what I understand, in_same_tax will show any posts in the taxonomy, regardless of the term value.

    I thought in_cats is supposed to filter by category ID, so I thought that if I put my taxonomy term ID as this value it would achieve what I want? Either I am doing it wrong or I assumed incorrectly. The term_id is 18 but if I put:

    ‘in_cats’ => ’18′,

    It behaves the same as if I don’t have that at all. (The last post with that taxonomy term still links to the first post in the next term.) I am willing to hack the plugin to achieve what I need but I’m not sure where to do it. I would really appreciate some guidance please! Great plugin otherwise, thank you.

  289. ambrosite says:

    @Sammii Based on the example you gave, it should be working the way you expect. I would need to take a closer look at your site in order to troubleshoot further. If you want to give me a link, I’ll check it out.

  290. Sammii says:

    @ambrosite Would it be possible for me to email you the info? It is a client’s dev site so I would rather not post the link on a public forum. I could also then email you the PHP snippets.

    Thank you so much for the help BTW, I really appreciate the plugin support. Like I said it’s for a client, and we’re getting close to deadline so I need to fix this ASAP! Haha.

  291. Trinzia says:

    Hi Ambrosite,
    I was wondering if you have seen a function anywhere, that will allow me to add some links to my theme. I’d like to include in my theme:
    - a link at top of page when user is logged in, to his own posts, if he has some
    - a link at top of page to his own comments, if he has them
    I have figured out links to add a post, etc, but these ones give me trouble & I had no Google-luck. Seen anything?
    Thanks!

  292. ambrosite says:

    @Trinzia Offhand I do not know of any solution for that, but I am sure you can find something suitable among the 20,000+ plugins that are now available for WordPress. If not, it shouldn’t be too hard to code.

  293. Trinzia says:

    Lol, not too hard, you say :) Your profile says you’ve been coding since you were about 7. I’m just a poor struggling UI designer, but thank you for both kind responses.

  294. ambrosite says:

    @Trinzia Well … I know no one wants to hear this, but if you want me to write custom code for you, I am available for hire. Let me know if you have any kind of budget for this, and I’ll try to work with it.

Comments are closed. If you have a question about this plugin, please create a thread on the WordPress support forum and I will answer it there.