Getting the Blog "Up To Date"

What if I don't want to publish the blog until a later date? When I'm blogging I'm blogging a lot and when I don't blog I never blog. So why not publish the blogs on a later date so my site updates more regularly like a blog site is suppose to do.

I only want to show blogs that have a date set to today or before. so I need a conditional that checks in each place the blogs are published to a menu, preview, and blog page.

if($blog['date'] <= date("Y-m-d"))

The PHP date function takes an argument of how to format the date. In this case my date is formatted Year-Month-Day. Now I can compare the two and see if the blog date is less than or equal to todays date.

So that's great it works but I have to add the conditional every place where the blogs are being queried. Why not skip all the conditionals and instead query all the blogs up to the current date.

SELECT * blogs WHERE date <= CURDATE()

I got rid of the PHP conditionals and updated two the queries for get_all_blogs and get_recent_blogs. Honestly the blog doesn't use that function because it shows all the blogs on the home page and not just the recent ones.

So that's it. Now my blog site only shows blogs that are up to date. Making my blog "up to date".

Comments

Looks like a good blog.

Looks like a good blog.