Title: Previous / Next Record Button
Last modified: October 26, 2023

---

# Previous / Next Record Button

 *  [KJW2912](https://wordpress.org/support/users/kjw2912/)
 * (@kjw2912)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/previous-next-record-button/)
 * Hi there,
 * Firstly thank you for your awesome plugin. I’ve been using it for well over 4
   years and find it absolutely superb for my website requirements.
 * This is quite an embarrassing question as I’m sure it’s simple Javascript.
 * I’m trying to create very simple button(s) for my Single Record page which will
   allow users to navigate to either the previous record or the next record. I’d
   probably use the “Record ID” as the query and then simply minus 1 or plus 1 for
   Previous and Next records.
 * At present I’ve added a “Back to previous page” button using a basic html form
   with an onclick=”history.back() function.
 * Rather than users having to return to the main pdb-list page and select the a
   previous or next record I was hoping there is a way of easily adding this functionality
   on the single record page (using buttons which I can style via CSS).
 * Thanks for any suggestions or code that would allow this. I’ve done some searching
   on the subject but unsure where to start and which route to take.
 * Any help much appreciated.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fprevious-next-record-button%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/previous-next-record-button/#post-17157237)
 * It is best to do this with php in a [custom template](https://xnau.com/work/wordpress-plugins/participants-database/participants-database-documentation/pdb-templates/)
   for the single record shortcode.
 * In your custom template, you will need to include code that determines the id
   of the next and previous records. This should happen at the top of the template.
   This is not as simple as adding or subtracting from the current id because it
   would be normal for there to be skipped ids (when records are deleted). So, you
   will need to query the database to make sure you have valid ids.
 * Once you have those two id numbers, you can use them to build the next and previous
   links, and then add them to the template where they can be displayed.
 * There isn’t any built-in way to do this because it’s not a thing most Participants
   Database administrators need, but given some skill with php it is not difficult.
 * Check this function for a way to get a list of ids from the database:
 * [Participants_Db::get_id_list( )](https://xnau.com/work/wordpress-plugins/participants-database/participants-database-documentation/participants-database-api/#getlist)
 *  Thread Starter [KJW2912](https://wordpress.org/support/users/kjw2912/)
 * (@kjw2912)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/previous-next-record-button/#post-17157789)
 * I’ll have a look at this. Thanks for your help.

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

The topic ‘Previous / Next Record Button’ is closed to new replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

## Tags

 * [buttons](https://wordpress.org/support/topic-tag/buttons/)

 * 2 replies
 * 2 participants
 * Last reply from: [KJW2912](https://wordpress.org/support/users/kjw2912/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/previous-next-record-button/#post-17157789)
 * Status: not resolved