Order pages by date 时间:2017-08-22 作者:Russell 我正在尝试制作一个onepager并将所有页面加载到一个页面中,如果这有意义的话?现在它是按阿尔法贝蒂的头衔订购的。我想按日期订购。这是网站:http://st358373.cmd16c.cmi.hanze.nl/aljen/home/我已经尝试过此方法,但Wordpress不会加载页面:Wrong Sub-Page Order$pages = get_pages(); foreach ($pages as $page_data) { $content = apply_filters(\'the_content\', $page_data->post_content); $title = $page_data->post_title; $slug = $page_data->post_name; echo "<div class=\'$slug\'>"; echo "<h2>$title</h2>"; echo $content; echo "</div>"; } 1 个回复 SO网友:kalidas 尝试在主题文件中使用以下过滤器。function orderby_date( $orderby, $query ) { global $wpdb; return str_replace( "{$wpdb->posts}.post_date", "CAST({$wpdb->posts}.post_date AS DATE)", $orderby ); } add_filter( \'posts_orderby\', \'orderby_date\', 10, 2 ); 结束 文章导航