In WP Travel, the Trip Extras Archive is a dedicated page that showcases all your available Trip Extrasβ€”such as meals, transport options, guided tours, and more. By default, these extras are listed in the order they were created or saved. To provide a more organized and user-friendly experience, you may want to sort the Trip Extras alphabetically (A–Z or Z–A) on this archive page.

You can achieve this with a simple code snippet.

Default sorting of trip extras on the Trip Extras Archive

Sort Trip Extras in Ascending Order

To display your Trip Extras in alphabetical order (A to Z), add the following code snippet to your site:

add_filter("wp_travel_list_tour_extras_orders", function(){
    return "asc";
});
Sorting of trip extras alphabetically in ascending order on the Trip Extras Archive

Sort Trip Extras in Descending Order

To display your Trip Extras in reverse alphabetical order (Z to A), use this code instead:

add_filter("wp_travel_list_tour_extras_orders", function(){
    return "desc";
});
Sorting of trip extras alphabetically in descending order on the Trip Extras Archive

Where to Add the Code?

You can add either of the above code snippets using one of the following methods:

  • Install and activate the Code Snippets plugin.
  • Go to Snippets > Add New.
  • Paste the code, give it a title like “Sort Trip Extras”, and click Save and Activate.

Option 2: Add to Your Child Theme’s functions.php File

  • Navigate to Appearance > Theme File Editor in your WordPress dashboard.
  • Select your child theme, then open the functions.php file.
  • Paste the code at the end of the file and click Update File.

πŸ’‘ Not using a child theme yet? Here’s how to create one.

Once applied, your Trip Extras will be displayed in the selected alphabetical order on the archive page, making it easier for users to browse and choose additional trip options.

Conclusion

By following this simple guide you can now provide a more organized and user-friendly experience by sorting the Trip Extras alphabetically.

Check WP Travel documentation to learn more about configurations, modules, payments, shortcodes, and the WP Travel Rest API.

Your feedback helps us improve. Please share your thoughts.

Need assistance? Contact our support team, join our Facebook community, and subscribe to our YouTube Channel for video tutorials. Thank you for choosing WP Travel.

Get WP Travel Pro