Here’s a stab at it. I’m not sure exactly what in your URL’s are taxonomies, or even what your taxonomies are, but basically you’d just have to loop through everything adding to the pages array with the arrays. You’d need to either define all your models in an array, or grab them from the database using something like get_option()
;
add_filter( 'bwp_gxs_external_pages', 'bwp_gxs_external_pages', 10, 1 );
function bwp_gxs_external_pages($pages)
{
$models = array( 'aston-martin', 'bmw', 'mercedes-benz' /*...*/ );
$locations = get_terms( array(
'taxonomy' => 'location',
'hide_empty' => true,
) );
// Loop through the search terms
foreach ( $models as $model ) {
foreach ( $locations as $location ) {
$pages[] = array(
'location' => home_url( '/used-cars/location/' . $location->slug . '/model/' . $model ),
'lastmod' => '27/03/2017',
'frequency' => 'auto',
'priority' => '0.8'
);
}
$pages[] = array(
'location' => home_url( '/used-cars/model/' . $model ),
'lastmod' => '27/03/2017',
'frequency' => 'auto',
'priority' => '0.8'
);
}
return $pages;
}
Hope this gets you started.