在有限时间内显示Wordpress帖子(取决于自定义字段的值)

问题描述:

我想在发布后的一段时间(1或2周)内显示Wordpress帖子。在创建自定义字段(advertorial_duur)期间,其价值为1(1周)或2(2周)。在有限时间内显示Wordpress帖子(取决于自定义字段的值)

它显示了一些帖子,但不是根据我在帖子中设置的持续时间。我无法弄清楚,但我认为它现在显示的职位只有1周,无论自定义字段值。

到目前为止,我已经生成此代码:

<ul class="advertorials"> 
    <?php 
    $advertorials = new WP_Query('cat=18'); 

    while ($advertorials->have_posts()) : 

     $advertorials->the_post();   

     if ((current_time(timestamp) - get_the_time('U') - (get_settings('gmt_offset') * 3600)) < ((int)get_post_custom_values('advertorial_duur'))*(7*60*60*24)) 
     { 
    ?> 

    <li><a href="<?php the_permalink(); ?>" title="Lees meer over: <?php the_title(); ?>"> 
     <div class="thumb"><?php the_post_thumbnail('thumbnail') ?></div> 
     <p class="title"><?php the_title(); ?></p> 
     <div class="clr"></div></a> 
    </li> 

    <?php } ?> 

    <?php endwhile; ?> 
    <?php wp_reset_query(); ?> 
</ul>  
+0

*它已经显示了一些帖子,但不是根据我在帖子中设置的持续时间*是一个微弱的错误描述。尝试精确这一点。 – 2014-10-30 13:33:00

你应该尝试的插件Post Expirator它可以让你设定的到期日期,如何到期,到期类的职位/页。但它不会使用自定义字段的值。