Hi Michael,
Basically I want to loop through these type of URLs www.example.com/used-cars/location/new-york/model/bmw
& www.example.com/used-cars/model/mercedes-benz
and push them into a sitemap.
add_filter( 'bwp_gxs_external_pages', 'bwp_gxs_external_pages', 10, 1 );
function bwp_gxs_external_pages($pages)
{
$models = get_terms( array(
'taxonomy' => 'vehicle_model',
'hide_empty' => false,
) );
$locations = get_terms( array(
'taxonomy' => 'vehicle_location',
'hide_empty' => false,
) );
// Loop through the search terms
foreach ( $models as $model ) {
$pages[] = array(
'location' => home_url( '/used-cars/model/' . $model->slug ),
'lastmod' => '27/04/2017',
'frequency' => 'auto',
'priority' => '0.8'
);
foreach ( $locations as $location ) {
$pages[] = array(
'location' => home_url( '/used-cars/location/' . $location->slug . '/model/' . $model->slug ),
'lastmod' => '27/04/2017',
'frequency' => 'auto',
'priority' => '0.8'
);
}
}
return $pages;
}
So a problem I encounter with this code is that, when I set the hide_empty
to true, I get only URLs with posts assigned to them, but then when I set it to false as it is in the code, I get a WSOD.
So my guess is that, the problem lies with get_terms