I want to highlight or show the new tag to the particular posts. When the user selects that the post the should be highlighted or show the new tag in the post list, the post should show new tag in the posts list in Front-end.
How I can achieve this?
The New tag means the new image or new text to highlight the post in the post list to draw user attention.
This is my code added in functions.php
:
function wpb_lastvisit_the_title ( $title, $id ) {
if ( !in_the_loop() || is_singular() || get_post_type( $id ) == 'page' ) return $title;
// Check the post with the new tag
$tag_ids = wp_get_post_tags($post->ID, array('fields' => 'ids'));
if ($tag_ids == 'new')
$title .= '<span class="new-article">New</span>';
return $title;
}
add_filter( 'the_title', 'wpb_lastvisit_the_title', 10, 2);
CSS:
.new-article {
background: #feffdd;
padding: 3px;
border: 1px solid #eeefd2;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
margin-left:5px;
font-size: small;
font-weight: bold;
}
Any help is much appreciated.