基本上,我希望在过去24小时内发布的帖子中添加这一行代码:
<span class="new">New!</span>
当帖子超过24小时后,删除内联HTML元素。
这是我到目前为止的代码,但不知道如何实现这个功能,有人有什么想法吗?
<section class="post-wrap">
<ul class="filter">
<li><a href="<?php bloginfo( \'url\' ); ?>/explorers">All</a></li>
<li><a href="<?php bloginfo( \'url\' ); ?>/category/stories" class="stories">Stories</a></li>
<li><a href="<?php bloginfo( \'url\' ); ?>/category/missions" class="missions">Missions</a></li>
<li><a href="<?php bloginfo( \'url\' ); ?>/category/questions" class="questions">Questions</a></li>
</ul>
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(\'posts_per_page=10\'.\'&paged=\'.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<?php if (in_category(3)) {?>
<article class="mission" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>">
<div class="headline">
<h1><?php the_title(); ?> <span><?php echo get_the_date(); ?></span></h1>
<?php global $more; $more = 0; the_content(\'\'); ?>
</div>
<div class="pseudo-link">Accept</div>
</a>
</article>
<?php } ?>
<?php if (in_category(4)) {?>
<article class="story" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>">
<span class="new">New!</span>
<div class="headline">
<h1><?php the_title(); ?> <span><?php echo get_the_date(); ?></span></h1>
<p><?php the_field(\'author_details\'); ?></p>
</div>
<div class="pseudo-link">Read more</div>
</a>
</article>
<?php } ?>
<?php if (in_category(5)) {?>
<article class="question" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
</article>
<?php } ?>
<?php endwhile;?>
<div class="next-prev">
<?php next_posts_link(\'Older Posts\') ?>
<?php previous_posts_link(\'Newer Posts\') ?>
</div>
<?php $wp_query = null; $wp_query = $temp; wp_reset_query(); ?>
</section>