I used to be making an attempt so as to add a picture like a “new” picture to the posts that are simply revealed and are lower than 2 days previous.
I attempted utilizing a operate like this inside a WP_Query however it’s making use of to all posts.
add_action('the_title', 'insiderable_add_img_new');
operate insiderable_add_img_new($title) {
$title = '<img src="https://insiderable.com/wp-content/uploads/2020/03/newicon.gif">'.$title;
return $title;
}
That is what I attempted with WP_Query:
$events_query = new WP_Query(array('post_type'=>'submit', 'post_status'=>'publish', 'posts_per_page'=>-1));
if($events_query->have_posts()) :
whereas($events_query->have_posts()) :
$events_query->the_post();
if (get_the_date( 'Y-m-d' ) === date( 'Y-m-d' )) {
add_filter('the_title', 'insiderable_add_img_new');
}
endwhile; else: endif;
wp_reset_postdata();
operate insiderable_add_img_new($title) {
$title = '<img src="https://insiderable.com/wp-content/uploads/2020/03/newicon.gif">'.$title;
return $title;
}