我使用这段php代码来显示Gig列表,这是一种自定义的post类型。我想按帖子的“时间”值排序,并忽略已经发生的演出。如何修改以下代码来实现这一点?
<?php
$args2 = array(
\'post_type\' => \'gig\',
\'numberposts\' => -1
);
$gigs = get_posts($args2);
foreach ($gigs as $gig){
echo \'<h2>\'.$gig->post_title.\'</h2><br />\';
// for each custom fields you want.
echo get_post_meta($gig->ID,\'_gigswhen\', true).\'</br>\';
echo \'Time: \'.get_post_meta($gig->ID,\'_gigsstart_time\', true).\'-\'.get_post_meta($gig->ID,\'_gigsend_time\', true).\'<br />\';
}
?>
为了澄清一点,这里是我函数中的代码。php
$config = array(
\'id\' => \'gigs-info\',
\'title\' => \'Gig Info\',
\'pages\' => array(\'gig\'),
\'context\' => \'normal\',
\'priority\' => \'high\',
\'fields\' => array(),
\'local_images\' => false,
\'use_with_theme\' => true //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
);
$my_meta = new AT_Meta_Box($config);
//Add fields to your meta box
$my_meta->addText($prefix.\'where\',array(\'name\'=> \'Where is the Gig \'));
$my_meta->addDate($prefix.\'when\',array(\'name\'=> \'When is the Gig \'));
$my_meta->addTime($prefix.\'start_time\',array(\'name\'=> \'When Does it Start \'));
$my_meta->addTime($prefix.\'end_time\',array(\'name\'=> \'When Does it End \'));
$my_meta->addText($prefix.\'with_who\',array(\'name\'=> \'With Who is the Gig \'));
$my_meta->addTextarea($prefix.\'words\',array(\'name\'=> \'A few words on the gig \'));
$my_meta->Finish();
}
?>
我使用的是一个定制的meta-box类文件,有人友好地指出了我。所以我不确定它是否保存为unix时间戳。。我对wordpress php编程有点陌生:)