Loading...


Loading...

Welcome!

Sign up for a free account, or log in here.

Member Login

You can login by following the link.

Not a Member? Sign up! It's Free!

Please feel free to register.

Click to log in.

2 comments

Determining if a Post was Posted Today

Yes, I know the title seems a little strange. From the admin section it’s easy as pie. Just click Posts and look at the date.

On the viewing side it’s easy too, but codewise, this is a way that can let you separate your posts, or do something special to those that have been posted today, maybe add a ‘New’ graphic, or ‘Posted Today’, or something like that.

Easy to do, like this:

$post_date = mysql2date(“Ymd”, $post->post_date);
if ($post_date == date(‘Ymd’)) {
?>
<div class=”post-new”> </div>
<?php
}

In this case it’s shown in the theme I created for Percent Savings, where a ‘New’ graphic is shown on the right side of the index page if there is a new post. You can do a whole slough of things though, maybe add some reply options?

I linked the mysql2date function to the Codex, it’s useful in this, and can be used for more than just the day. Perhaps you want to highlight an entire week, or the last hour (if you have a -really- busy blog)?

Trackbacks

[...] link: Determining if a Post was Posted Today Related Posts:Determining if a Post was Posted Today[php code] import wordpress posts from excel [...]

[...] post: Determining if a Post was Posted Today Related Posts:Determining if a Post was Posted Today[php code] import wordpress posts from excel [...]



Leave a Reply



You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


The English Guy on Twitter

Raised Paper WordPress Theme

Raised Paper WordPress Theme screenshot
Theme Price

Onyx WordPress Theme

Onyx WordPress Theme screenshot
Theme Price

Victoriana WordPress Theme

Victoriana WordPress Theme screenshot
Theme Price

Expression Blue WordPress Theme

Expression Blue WordPress Theme screenshot
Theme Price

Premium WordPress Theme Release: Natural Green

Premium WordPress Theme Release: Natural Green screenshot
Theme Price

Theme Release: Ikon WordPress Theme

Theme Release: Ikon WordPress Theme screenshot
Theme Price

Shocking WordPress Theme Release

Shocking WordPress Theme Release screenshot
Theme Price

Digitalis WordPress Theme Release

Digitalis WordPress Theme Release screenshot
Theme Price

WordPress Theme: OpenAir Theme

WordPress Theme: OpenAir Theme screenshot
Theme Price

WordPress Theme: Very English

WordPress Theme: Very English screenshot
Theme Price

News Print v3.0 WordPress Theme Released

News Print v3.0 WordPress Theme Released screenshot
Theme Price

Reclamation WordPress Theme

Reclamation WordPress Theme screenshot
Theme Price