Ah, figured it out for anyone that’s interested. The order variable never gets passed to the custom post type items function. To fix this you need to add the $order variable here in the plugin’s wp-sitemap-page.php file (edits have ‘strong’ tags around them… don’t copy the strong tags into the php code):
if ( !empty($cpt) ) {
return wsp_return_content_type_cpt_items( $is_title_displayed, $display_nofollow, $cpt, $only_cpt, $wsp_exclude_pages, $sort, <strong>$order</strong> );
}
Then within the wsp_return_content_type_cpt_items function (edits have ‘strong’ tags around them… don’t copy the strong tags into the php code):
function wsp_return_content_type_cpt_items( $is_title_displayed=true, $display_nofollow=false, $cpt, $post_type, $wsp_exclude_pages, $sort=null, <strong>$order=null</strong> ) {
// init
$return = '';
// List the pages
$list_pages = '';
// define the way the pages should be displayed
$args = array();
$args['post_type'] = $post_type;
$args['posts_per_page'] = 999999;
$args['suppress_filters'] = 0;
// exclude some pages ?
if (!empty($wsp_exclude_pages)) {
$args['exclude'] = $wsp_exclude_pages;
}
// change the sort order
if ($sort!==null) {
$args['orderby'] = $sort;
}
<strong>if ($order!==null){
$args['order'] = $order;
}</strong>
// Query to get the current custom post type
$posts_cpt = get_posts( $args );
// display a nofollow attribute ?
$attr_nofollow = ($display_nofollow==true ? ' rel="nofollow"' : '');
// List all the results
if ( !empty($posts_cpt) ) {
foreach( $posts_cpt as $post_cpt ) {
$list_pages .= '<li><a href="'.get_permalink( $post_cpt->ID ).'"'.$attr_nofollow.'>'.$post_cpt->post_title.'</a></li>'."\n";
}
}
// Return the data (if it exists)
if (!empty($list_pages)) {
if ($is_title_displayed==true) {
$return .= '<h2 class="wsp-'.$post_type.'s-title">' . $cpt->label . '</h2>'."\n";
}
$return .= '<ul class="wsp-'.$post_type.'s-list">'."\n";
$return .= $list_pages;
$return .= '</ul>'."\n";
}
// return content
return apply_filters( 'wsp_cpts_return', $return );
}