The group size displayed on the single trip page is a crucial detail for potential travelers, outlining the minimum and maximum number of participants allowed for a trip. Customizing the group size allows you to tailor its presentation and enhance your website’s design and user experience. A presentation website can be a great tool to showcase this customization and improve your site’s overall visual appeal. This short guide will help you customize the Group Size on the Single Trip Page.

The group size information is derived from the trip’s pricing details, specifically the min_pax (minimum group size) and max_pax (maximum group size) values. Below are examples of how you can customize the display and details on both single trip and archive pages.

Single trip page showcasing the Group size limit of the trip.

Adding the Code

To implement the customizations, add the following code snippets to the functions.php file of your child theme or use a plugin like code snippets to safely add custom PHP.

Customizing Group Size Display

1. Change Text Labels

This snippet modifies the group size display to show both the minimum and maximum values in the format:
“Minimum 1 – Maximum 20”.

function wp_travel_custom_single_archive_group_size( $group_size, $trip_id ) {
    $min = 0;
    $max = 0;
    foreach(  WP_Travel_Helpers_Trips::get_trip($trip_id )['trip']['pricings'] as $data ){
        if( $min < $data['min_pax'] ){
            $min = $data['min_pax'];
        }
        if( $max < $data['max_pax'] ){
            $max = $data['max_pax'];
        }
    }
    return '<li>
            <div class="travel-info">
                <strong class="title">Group Size</strong>
            </div>
            <div class="travel-info">
                <span class="value"> Minimum ' . $min . ' -  Maximum ' . $max . '</span>
            </div>
        </li>';
}
// Add the filter to modify the group size
add_filter( 'wp_travel_single_archive_group_size', 'wp_travel_custom_single_archive_group_size', 10, 2 );
Group size displaying both minimum and maximum values after modification in the single trip page.

2. Display Only the Minimum Group Size

To show only the minimum group size along with the label “Minimum”, use the following snippet:

function wp_travel_custom_single_archive_group_size( $group_size, $trip_id ) {
    $min = 0;
    $max = 0;
    foreach(  WP_Travel_Helpers_Trips::get_trip($trip_id )['trip']['pricings'] as $data ){
        if( $min < $data['min_pax'] ){
            $min = $data['min_pax'];
        }
        if( $max < $data['max_pax'] ){
            $max = $data['max_pax'];
        }
    }
    return '<li>
            <div class="travel-info">
                <strong class="title">Group Size</strong>
            </div>
            <div class="travel-info">
                <span class="value"> Minimum ' . $min = $data['min_pax'] .
                '</span>
            </div>
        </li>';
}
// Add the filter to modify the group size
add_filter( 'wp_travel_single_archive_group_size', 'wp_travel_custom_single_archive_group_size', 10, 2 );
Group size displaying only minimum values after modification in the single trip page.

3. Display Only the Maximum Group Size

To show only the maximum group size along with the label “Maximum”, use this snippet:

function wp_travel_custom_single_archive_group_size( $group_size, $trip_id ) {
    $min = 0;
    $max = 0;
    foreach(  WP_Travel_Helpers_Trips::get_trip($trip_id )['trip']['pricings'] as $data ){
        if( $min < $data['min_pax'] ){
            $min = $data['min_pax'];
        }
        if( $max < $data['max_pax'] ){
            $max = $data['max_pax'];
        }
    }
    return '<li>
            <div class="travel-info">
                <strong class="title">Group Size</strong>
            </div>
            <div class="travel-info">
                <span class="value"> Maximum ' . $max = $data['max_pax'] .
                '</span>
            </div>
        </li>';
}
// Add the filter to modify the group size
add_filter( 'wp_travel_single_archive_group_size', 'wp_travel_custom_single_archive_group_size', 10, 2 );
Group size displaying only maximum values after modification in the single trip page.

Conclusion

By following the steps above, you can effectively customize the Group Size on the Single Trip Page to align with your design and user experience goals.

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