2011-06-21 24 views
0

我使用以下代碼來隱藏過去在wordpress中的帖子(日期來自我製作的自定義字段稱爲日期) - 問題是其還躲在來設定的,以今天的日期以及過去在wordpress中的項目失效日期 - 不顯示當前日期

<?php query_posts($query_string.'&posts_per_page=24&order=desc&orderby=meta_value&meta_key=date'); ?> 

<?php while (have_posts()) : the_post(); 
$date = get_post_meta($post->ID, 'date', true); 
if ($date){ 
$mydate = "$date"; 
echo date('l, j F, Y', strtotime($mydate)); 

} 
?> 

任何想法如何得到它允許職位,其中自定義字段是今天的日期?

謝謝!

回答

0

最後我用這個..

<?php  while (have_posts()) : the_post(); 
//to check against expiration date; 
$currentdate = date("Ymd"); 
$expirationdate = get_post_custom_values('date'); 
if (is_null($expirationdate)) { 
$expirestring = '30005050'; //MAKE UN-EXPIRING POSTS ALWAYS SHOW UP; 
} else { 
if (is_array($expirationdate)) { 
$expirestringarray = implode($expirationdate); 
} 
$expirestring = str_replace("/","",$expirestringarray); 
} //else 
if ($expirestring >= $currentdate) { ?> 

loop goes in here 

<?php } ?> 

說實話我不記得在那裏我找到了它 - 但如果有人能neaten起來,將是偉大的!