OrderBy non funziona per query_posts utilizzando l'array di IDS
-
02-11-2019 - |
Domanda
Ho una matrice di ID che invio a query_posts per ottenere i post (che funziona bene) ma sembra mettere sempre l'Allegato (562) per ultimo anche se è il più recente. Hai anche provato il titolo e ASC vs Desc ma è sempre ultimo?
$slide_args = array(
'post_type' => 'attachment',
'post_status' => 'inherit',
'fields' => 'ids',
'tax_query' => array(
array(
'taxonomy' => 'media_tag',
'terms' => 'new-work',
'field' => 'slug',
)
)
);
$slide_attachments = new WP_Query($slide_args);
$sticky_ids = get_option('sticky_posts');
$slideshow_posts = array_merge($slide_attachments->posts,$sticky_ids) ;
// creates Array ( [0] => 562 [1] => 479 [2] => 598 [3] => 686 )
// 562 is an attachment, the others are posts
$postsargs = array(
'orderby' => 'date',
'order' => 'DESC',
'post_status' => 'published',
'post_type' => array( 'attachment', 'post' ),
'post__in' => $slideshow_posts,
);
query_posts( $postsargs );
Qualcuno sa cosa potrebbe succedere? Best, DC.
Nessuna soluzione corretta
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange