Title: Prev/Next code
Last modified: March 2, 2021

---

# Prev/Next code

 *  Resolved [atventure](https://wordpress.org/support/users/atventure/)
 * (@atventure)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/prev-next-code/)
 * I’ve been searching to see if there is a way for the pods to create a Prev and
   Next link specifically to a category within the same pods post-type. I’ve tried
 * [pods name=”PODSNAME” limit=”1″ id=”current” orderby=”previous” where=”LOCATION.
   slug=’CATEGORY1′.”]
    [Previous](https://wordpress.org/support/topic/prev-next-code/{@permalink}?output_format=md)[/
   pods]
 * and
 * [pods name=”PODSNAME” limit=”1″ where=”LOCATION.slug=’CATEGORY1′”]
    [Next](https://wordpress.org/support/topic/prev-next-code/{@peramlink}?output_format=md)[/
   pods]
 * I am not sure if the id and orderby even accepts the command I’ve placed (amateur
   here). Not sure what else can be added or exclude.
 * The other thing I could do is use the site template’s Prev/Next but it will capture
   all the post created instead of the specific category.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Jory Hogeveen](https://wordpress.org/support/users/keraweb/)
 * (@keraweb)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/prev-next-code/#post-14126690)
 * Hi [@atventure](https://wordpress.org/support/users/atventure/)
 * You cannot order by “previous” since there is no such thing in the WP database.
 * I will point you to the documentation (PHP) about this part of WordPress:
    [https://developer.wordpress.org/reference/functions/get_previous_post_link/](https://developer.wordpress.org/reference/functions/get_previous_post_link/)
   [https://developer.wordpress.org/reference/functions/get_adjacent_post_link/](https://developer.wordpress.org/reference/functions/get_adjacent_post_link/)
 * Keep in mind that this depends on WP_Query, not Pods queries.
 * One thing you could try with the shortcode is to sort by date and limit to 1.
   
   This would result in something like this: `[pods name="PODSNAME" limit="1" where
   ="LOCATION.slug ='CATEGORY1' AND post_date > 'Current post date'" orderby="post_date
   ASC"]`
 * Cheers, Jory
 *  Thread Starter [atventure](https://wordpress.org/support/users/atventure/)
 * (@atventure)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/prev-next-code/#post-14128904)
 * I see, I was trying to set the shortcode so there would be no need to continuously
   edit for new posts.
 * I will try out your shortcode and look into the links provided. Thank you!
 *  Thread Starter [atventure](https://wordpress.org/support/users/atventure/)
 * (@atventure)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/prev-next-code/#post-14129528)
 * Following up with the shortcode: unable to get the
 * >  AND post_date > ‘Current post date'”
 *  to work.
    I tried the where=”LOCATION.slug=’CATEGORY1′ AND post_date=’yyyy-mm-
   dd’ ” and outside of where: post_date=”yyyy-mm-dd”. Site was unable to show the
   shortcode. When it does show, the ascending order is the initial post of the 
   category and the descending order is the newest post of the category and not 
   directly the previous or next of the current post.
 * Not sure how else to specify the current post date within the shortcode.
 *  Plugin Author [Jory Hogeveen](https://wordpress.org/support/users/keraweb/)
 * (@keraweb)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/prev-next-code/#post-14133092)
 * Are you using this code within a Pod template?
    Also, have you checked the query
   that was made? (Add &pods_debug_sql=1 to your URL).
 * Let me know!
 * Cheers, Jory
 *  Thread Starter [atventure](https://wordpress.org/support/users/atventure/)
 * (@atventure)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/prev-next-code/#post-14134778)
 * The code was used on the post.
 * Fatal error: Uncaught ArgumentCountError: Too few arguments to function PodsData::
   get_sql()`, 0 passed in ...PodsData.php on line 718 and exactly 1 expected in...
   PodsData.php:3528 Stack trace: #0 ...PodsData.php(718): PodsData->get_sql() #
   1 ...Pods.php(2715): PodsData->select(Object(stdClass)) #2 ...plugins/pods/includes/
   general.php(1057): Pods->find(Object(stdClass)) #3 ...pods/includes/general.php(
   763): pods_shortcode_run(Array, '<br />\n<a href=...') #4 ...shortcodes.php(343):
   pods_shortcode(Array, '<b in ...pods/classes/PodsData.php on line 3528`
 *  Plugin Author [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * (@sc0ttkclark)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/prev-next-code/#post-14134808)
 * There’s a fix for the debug SQL issue in Pods 2.8, I’ll see about getting that
   fix brought into this next upcoming Pods 2.7.x release.
    -  This reply was modified 5 years, 2 months ago by [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/).

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Prev/Next code’ is closed to new replies.

 * ![](https://ps.w.org/pods/assets/icon.svg?rev=3286397)
 * [Pods - Custom Content Types and Fields](https://wordpress.org/plugins/pods/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pods/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pods/)
 * [Active Topics](https://wordpress.org/support/plugin/pods/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pods/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pods/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/prev-next-code/#post-14134808)
 * Status: resolved