Zeige zukünftige Beiträge im Archiv an

Ich verwende den folgenden Code, um ein Archiv mit Posts anzuzeigen.

get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC" ); // For each year, do the following foreach ( $years as $year ) { // Get all posts for the year $posts_this_year = $wpdb->get_results( "SELECT * FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' AND post_status = 'future' AND YEAR(post_date) = '" . $year->year . "' ORDER BY post_date DESC" ); foreach ( $posts_this_year as $post ) { // echoing miscellaneous stuff } } ?> 

Dort heißt es post_status = 'publish' . Wie kann ich zukünftige Posts zu meinem Archiv hinzufügen? Ich habe versucht, AND post_status = 'future' zu beiden $wpdb->get_results Einträgen $wpdb->get_results aber es funktioniert nicht.

Solutions Collecting From Web of "Zeige zukünftige Beiträge im Archiv an"

Sie müssen “ODER” anstelle von “UND” verwenden,

 < ?php // Get years that have posts $years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND (post_status = 'publish' or post_status = 'future') GROUP BY year DESC" ); // For each year, do the following foreach ( $years as $year ) { // Get all posts for the year $posts_this_year = $wpdb->get_results( "SELECT * FROM wp_posts WHERE post_type = 'post' AND (post_status = 'publish' OR post_status = 'future') AND YEAR(post_date) = '" . $year->year . "' ORDER BY post_date DESC" ); foreach ( $posts_this_year as $post ) { // echoing miscellaneous stuff } } ?>