Viewing 6 replies - 1 through 6 (of 6 total)
  • Bumping up this post since I’m having the same issue. Is there anyone that could help?

    Same for me. Displaying Z-A instead of the other way round. Is there an ascending attribute or something?

    I’m having this same issue. I’ve tried the following shortcodes, and it displays the posts from Z -> A both ways.

    [wp_sitemap_page only=”things_to_do” sort=”post_title” order=”ASC”]
    [wp_sitemap_page only=”things_to_do” sort=”post_title” order=”DESC”]

    Here is the sample output: https://visithillsboroughnc.aclients.com/site-map/

    The top Things to Do section is using the [wp_sitemap_page only=”things_to_do” sort=”post_title” order=”ASC”] shortcode.

    The bottom Things to Do section is using the [wp_sitemap_page only=”things_to_do” sort=”post_title” order=”DESC”] shortcode.

    Any help is greatly appreciated!
    Thanks!

    Here is the sample output: https://visithillsboroughnc.aclients.com/site-map/

    The top Things to Do section is using the [wp_sitemap_page only=”things_to_do” sort=”post_title” order=”ASC”] shortcode.

    The bottom Things to Do section is using the [wp_sitemap_page only=”things_to_do” sort=”post_title” order=”DESC”] shortcode.

    Any help is greatly appreciated!
    Thanks!

    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 );
    }

    I would not want to start making changes to the code. Is it possible that the developer of this plugin will be making the correction soon?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘sort in alphabetical order’ is closed to new replies.