WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Change sort order to Menu Order (3 posts)

  1. Patrick
    Member
    Posted 3 years ago #

    Hi there,

    I have a function built into a theme that creates a list of subpages using a shortcode. It allows you select 'ASC' or 'DESC' to choose the sort order. However, is it possible to use menu_order here?

    Thanks in advance

    if ($order == 'ASC' && $parent == true ){
    				if ($current_url==$parent_url){ $extra = "class='current' "; }else{ $extra = null; }
    				$src.= '<li '.$extra.'><a href="'.$parent_permalink.'">'.$parent_title.'</a></li>';
    			}
    
    			while ($wp_query_childs->have_posts()) : $wp_query_childs->the_post();
    				$item_url = str_replace(array('http://', 'https://'),'',strtolower(get_permalink()));
    
    				if ($current_url==$item_url){
    					$extra = "class='current' ";
    				}else{
    					$extra = null;
    				}
    
    				$src.= '<li '.$extra.'><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
    			endwhile;
  2. Patrick
    Member
    Posted 3 years ago #

    What I mean't to say waht sort the list by menu_order, rather than ASC or DESC

    Thanks

  3. Patrick
    Member
    Posted 3 years ago #

    All sorted now, just needs to change the "orderby" to 'menu_order'

Topic Closed

This topic has been closed to new replies.

About this Topic