最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

loop - How to add “NEW” badge on latest posts or published 3 days interval

programmeradmin0浏览0评论

i make a news blog and i need your help for adding a "new" icon on the automatically inside all loops ( home page - Archive & Latest posts page ) like the photo.

Thanks in advance

here the loop code i'm using for latest posts list

<?php
// the query
$the_query = new WP_Query( array(
       'posts_per_page' => 6,
       //'offset' => 1 // excludes the first post in the query
   ));
$ids = array();
?>

i make a news blog and i need your help for adding a "new" icon on the automatically inside all loops ( home page - Archive & Latest posts page ) like the photo.

Thanks in advance

here the loop code i'm using for latest posts list

<?php
// the query
$the_query = new WP_Query( array(
       'posts_per_page' => 6,
       //'offset' => 1 // excludes the first post in the query
   ));
$ids = array();
?>
Share Improve this question edited Sep 19, 2019 at 13:51 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Sep 19, 2019 at 13:22 MIDOMIDO 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can add your "New badge logic" into your loop
while ( $loop->have_posts() ) : $loop->the_post(); or use the content filter.
There you can use get_the_date() function to calculate how old a post is and if it get's an icon or not.

发布评论

评论列表(0)

  1. 暂无评论