WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to add text to posts older than 1 month (3 posts)

  1. nims
    Member
    Posted 1 year ago #

    I want to add a specific text in single.php for the posts that are more than 1 month old. How can I do that ?

  2. prionkor
    Member
    Posted 1 year ago #

    It should be something like this. Add it to single.php file:

    $months_earlier = time() - 30*24*60*60;
    $post_published = get_the_time('U');
    
    if($months_earlier > $post_published){
    	// this is a 30 days old post. Echo your message here.
    }

    Used: http://codex.wordpress.org/Function_Reference/get_the_time

  3. nims
    Member
    Posted 1 year ago #

    thnks it helped :-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.