Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
按字母顺序排序<;选项>;使用php_Php_Sorting - Fatal编程技术网

按字母顺序排序<;选项>;使用php

按字母顺序排序<;选项>;使用php,php,sorting,Php,Sorting,我试图按字母顺序对期权价值进行排序,但我不确定最好的方法。目前,代码很好地列出了属性标题,但没有特别的顺序。这是我的代码: <label><?php _e('Property Name', 'framework'); ?></label> <select id="pname" style="box-shadow: none;" name="titl" class="form-control input-lg" > <option value=

我试图按字母顺序对期权价值进行排序,但我不确定最好的方法。目前,代码很好地列出了属性标题,但没有特别的顺序。这是我的代码:

<label><?php _e('Property Name', 'framework'); ?></label>
<select id="pname" style="box-shadow: none;" name="titl" class="form-control input-lg" >
<option value="Any">Any</option>
<?php 
  $temp = $wp_query; 
  $wp_query = null; 
  $wp_query = new WP_Query(); 
  $wp_query->query('showposts=-1&post_type=property'); 

  while ($wp_query->have_posts()) : $wp_query->the_post(); 
?>

<option value="<?php the_permalink(); ?>"><?php the_title(); ?></option>

<?php endwhile; ?>

<?php 
  $wp_query = null; 
  $wp_query = $temp;  // Reset
  wp_reset_query();
?>

</select>

任何

尝试订购ASC和按标题订购

那应该行

试试这个

$wp_query = new WP_Query(array(   
    'showposts'  => -1,
    'post_type'  => 'property',      
    'order'      => 'ASC',
    'orderby'    => 'title'
));

try:$wp_query=newwp_query(数组('orderby'=>'title','order'=>'DESC'));
$wp_query = new WP_Query(array(   
    'showposts'  => -1,
    'post_type'  => 'property',      
    'order'      => 'ASC',
    'orderby'    => 'title'
));