query_posts non ordina per titolo
Sembra un bug stupido, ma come posso ordinare per titolo? Continua comunque ad ordinare per data! Sto usando:
query_posts( array(
'post_type' => 'page',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC'
) );
Voglio utilizzare questo in una funzione come SHORTCODE. Quello che sto cercando di ottenere è creare una mappa del sito / indice di tutte le voci in ordine alfabetico. Inoltre sto usando l'ultima versione di WP.

Grazie a Chip Bennett che mi ha fatto notare che sbagliavo utilizzando query_posts
all'interno del contenuto. Quindi ho usato get_posts
e ho ottenuto ciò che volevo, grazie!
Ecco un esempio di come puoi farlo, se hai lo stesso problema che avevo io:
function qualche_nome(){
global $post;
$tmp_post = $post;
$args = array( 'post_type'=>'page', 'numberposts' => -1, 'orderby'=> 'title', 'order' => 'ASC' );
$myposts = get_posts( $args );
if ( !empty($myposts) ) {
foreach( $myposts as $post ) : setup_postdata($post);
the_title();
echo '<br>';
endforeach;
}
$post = $tmp_post;
}

Un altro post contiene questo codice all'interno di una funzione, ma per chi cerca semplicemente di aggiungere post in ordine alfabetico a un tema personalizzato, ad esempio, è possibile utilizzare quanto segue...
<?php // Ordina i post dalla categoria *** in ordine alfabetico
global $post;
$temp_post = $post;
$args = array( 'category' => *categoryID*, 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' );
$these_posts = get_posts( $args );
if( !empty($these_posts) ) {
foreach( $these_posts as $post ) : setup_postdata($post);
?>
<?php
/* HTML/PHP code goes here to display each post */
the_title("<h2>", "</h2>");
the_content("<div class='content'>", "</div>");
?>
<?php
endforeach; // Fine del Loop.
}
$post = $temp_post;
?>
