WordPress.org

Ready to get started?Download WordPress

Plugin Directory

WP_Query Powered Adjacent Post Link

A plugin for developers, WP_Query Powered Adjacent Post Link gives developers previous and next post buttons based on WP_Query arguments.

Usage

wpqpapl($post_id,$args,$adj,$return);

$post_id Pass the current post ID so the function knows what to check adjacency relative to. (required)

$args Pass arguments which will be fed directly into the WP_Query class. Be alert for errors which occur at this step as not all errors are handled by the plugin. (required)

$adj Pass either 'previous' or 'next'. You get the idea. (required)

$return Pass what you want returned. Pass nothing and the function will return the entire post object for the adjacency you have selected. The string can be any of the following: - "ID" - "title" - "slug" - "permalink"

The plugin always returns information, so use it in conjunction with echo(); in your theme.

Example:

In this example I gather the permalink to the previous post while specifying arguments for a WP_Query result which matches the desired results.

$args = array(  
    'post_type' => 'my_custom_post_type',  
    'orderby' => 'menu_order'  
);  
$previous_post_link = wpqpapl($post->ID,$args,'previous','permalink');

Requires: 3.3 or higher
Compatible up to: 3.5.2
Last Updated: 2012-12-16
Downloads: 340

Ratings

5 stars
5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.