我做错了什么
代码如下:
函数agendados(){
global $wpdb;
$ids = array();
$todaysDate = date(\'Y-m-d H:i:s\');
$hoje = strtotime($todaysDate);
$query = "SELECT post_date, ID from $wpdb->posts WHERE post_status=\'publish\'";
$posts = $wpdb->get_results($query);
if ($posts):
foreach ($posts as $post) {
$data_post = $post->post_date;
$str = strtotime($data_post);
if ($str < $hoje) {
$ids[] = $post->ID;
}
}
endif;
return $ids;
}
add\\u action(\'wp\\u head\',\'agendados\');
然后:
全球$ids;
$args = array (
\'post__not_in\' => $ids,
\'showposts\' => 30,
\'order\' => ASC,
);
global $post;
$posts = get_posts($args);
if ($posts) {
foreach ($posts as $post) {
setup_postdata($post);
$data = get_the_date(\'Y-m-d\');
echo $data;echo \'<br/>\';
}
}
$ids数组未包含任何内容:/