Skip Navigation

[Closed] Single result with pagination

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqas 9 years, 5 months ago.

Assisted by: Waqas.

Author
Posts
#263658

I am trying to:

Display a single result from a custom post type ("Client Videos") along with thumbnail navigation for the next/previous 2 videos.

I can pull the single video (sorted by 'video order' meta) but I am perplexed at how to include thumbnails from the 2 previous and 2 successive posts to be used as navigation.

If you could point me in the right direction, that would be very helpful!

thanks much!

#263760

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

You can use get_adjacent_post() Word Press API function for this, but you may need to create a custom short code to retrieve this, like:

add_shortcode("wpv-adjacent-post", "wpv_adjacent_post");

function wpv_adjacent_pst($atts) {
	$dir = $atts["dir"];
	
	if($dir == "next") {
		$adj_post = get_adjacent_post( true, '', false, 'category_name' );
	}
	
	if($dir == "prev") {
		$adj_post = get_adjacent_post( true, '', true, 'category_name' );
	}
	
	if ( !empty( $adj_post ) ) {
		// You can do further processing here
		// i.e. retrieve featured image and post meta
		// And can format the output accordingly.
	
		return $adj_post->ID;
	}
	
	return "";
}

Then you can use the short code in the loop of your view as:

[wpv-adjacent-post dir="prev"]
...
[wpv-adjacent-post dir="next"]

For more information on get_adjacent_post() please see http://codex.wordpress.org/Function_Reference/get_adjacent_post

The topic ‘[Closed] Single result with pagination’ is closed to new replies.