Come posso visualizzare questi post in ordine crescente?
Sto cercando di visualizzare alcuni post in ordine crescente, partendo dal primo creato fino al post creato più recentemente. Ogni aiuto è apprezzato. Ecco il mio codice:
<?php
$numofmebers = '-1';
if ( empty($_GET['page_id_all']) ) $_GET['page_id_all'] = 1;
$count_post = 0;
// Query per tutti i post di tipo coach-instructor pubblicati
query_posts( array( 'posts_per_page' => '-1', 'post_type' => 'coach-instructor' ,'post_status' => 'publish') );
while ( have_posts()) : the_post();
$count_post++;
endwhile;
if ( $node->instructor_pagination == "Single Page" ) {$node->instructor_page_num = -1;}
// Query principale con paginazione
query_posts( array('posts_per_page' => "$node->instructor_page_num", 'paged' => $_GET['page_id_all'], 'post_type' => 'coach-instructor' ,'post_status' => 'publish') );
$counter_news = 0;
while ( have_posts()) : the_post();
$counter_news++;
$image_id = get_post_thumbnail_id ( $post->ID );
$coach_istructor_meta = get_post_meta($post->ID, "cs_coach_istructor_meta", true);
if ( $coach_istructor_meta <> "" ) {
$xmlObject_author = new SimpleXMLElement($coach_istructor_meta);
// Recupero dei metadati dell'istruttore
$about = $xmlObject_author->about;
$specialism = $xmlObject_author->specialism;
$qualifications = $xmlObject_author->qualifications;
$philosophy = $xmlObject_author->philosophy;
$contact = $xmlObject_author->contact;
}
else {
// Valori predefiniti se non ci sono metadati
$about = '';
$specialism = '';
$qualifications = '';
$philosophy = '';
$contact = '';
}
?>

Tieni presente che query_posts è meglio evitarlo in quanto ha effetti negativi sul loop principale. Un approccio migliore sarebbe creare una nuova istanza di WP_Query o modificare gli argomenti della query per il loop principale.
Per ottenere l'ordinamento desiderato, prova ad aggiungere quanto segue ai tuoi argomenti:
array( 'posts_per_page' => '-1', 'post_type' => 'coach-instructor' ,'post_status' => 'publish', 'orderby' => 'date', 'order' => 'ASC')

Benvenuto su WPSE! I parametri che stai passando alla query non sono validi. orderby
può essere un array, ma in quel caso la "colonna di ordinamento" (precisamente il valore che denota la colonna) deve essere una chiave nell'array, non un valore.
L'uso di un array in orderby
dovrebbe essere così: $args = array( "orderby" => array("date"=>"DESC") )
.
