Mostrare Post di WordPress per Data

16 set 2015, 11:46:23
Visualizzazioni: 3.66K
Voti: 0

Voglio mostrare i post di WordPress per giorno/data nella homepage.

es:

Lunedì, 03 Gennaio

  • post 1
  • post 2
  • post 3

Domenica, 02 Gennaio

  • post 1
  • post 2
  • post 3

Sabato, 01 Gennaio

  • post 1
  • post 2
  • post 3

Quale query di WordPress dovrei usare?

Grazie. Scusate per il mio inglese.

0
Tutte le risposte alla domanda 1
1

Penso che la tua domanda sia stata risposta qui

$args = array('posts_per_page' => -1, 'orderby' => 'date' );
$myQuery = new WP_Query($args);
$date = '';
if ( $myQuery->have_posts() ) : while ( $myQuery->have_posts() ) : $myQuery->the_post();
if ( $date != get_the_date() ) {
    echo $date;
    echo '<hr />';
    $date = get_the_date();
}
the_title(); // o qualsiasi altra cosa tu voglia qui.
echo '<br />';
endwhile; endif;
wp_reset_postdata();

Maggiori informazioni sulla query qui: http://codex.wordpress.org/Class_Reference/WP_Query

16 set 2015 12:17:01
Commenti

Tieni presente che normalmente vorresti inserire il codice sopra all'interno di un template; idealmente in un Child Theme, in modo che gli aggiornamenti del tema non sovrascrivano le tue modifiche

Rick Hellewell Rick Hellewell
14 ago 2018 01:42:34