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

i make a news blog and i need your help for adding a "new" icon on the automatically inside all loops ( home p

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745146700a4613680.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信