• Hello,

    I was wondering if it were possible to have it so that when a new post is published a small image (New!) would appear beside the post’s title indicating its new. It’s just for people who drop onto my website and are wondering what the current posts are.

    Any suggestions?

Viewing 4 replies - 1 through 4 (of 4 total)
  • That should be possible by modifying the Loop in your theme’s index.php template file but how would you define “new”?

    Thread Starter P

    (@inkedkoi)

    I’d like to have the post title, and then when I publish a new post a little image that says “New” would appear beside the title.

    I would have to be able to give it a period of time that the image of “New” beside the post title, but I haven’t the faint idea what code I would need to do to make something like this work

    one possibility: http://wordpress.org/support/topic/mark-new-posts-as-new?replies=4

    details depend on your used theme.

    try forum search http://wordpress.org/search/mark+new+post

    I’ve previously used something like:

    /* Add span to title on newly posted posts/pages Requires my_is_new() */
    function my_highlight_new($title) {
    	global $post, $my_options;
    	if( !is_attachment() && in_the_loop() )  $title .= my_is_new();
    	return $title;
    }
    add_action('the_title', 'my_highlight_new');
    
    /*
    Determine if a given post/page can be classed as 'new'. Used by  my_highlight_new() */
    function my_is_new() {
    	global $post, $my_options;
    	$diff = date('U') - get_the_time('U', $post);
    	if ( $diff < 604800 ) return ' <span class="new"></span>'; // default: 1 week
    }

    in a theme’s functions,php file and then used CSS to add an image on the class .new.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Having an image appear when a post is newly published.?’ is closed to new replies.