Get Latest Post?
- FrederickGeek8
- Posts: 148
- Joined: Wed Nov 30, 2011 10:31 pm
Get Latest Post?
What is a good way, from your Blogging tutorial, to get the latest post and output it on a page (a preview of course)
Re: Get Latest Post?
Didn't I make a function to get the latest X posts ? Or the posts on a certain page, I think it was somethign like
function get_posts($page, $per_page);if so they you can use this,
$latest = current(get_posts(1, 1));to get the latest post. It's a slight misuse of the function, but probably what I would do
- FrederickGeek8
- Posts: 148
- Joined: Wed Nov 30, 2011 10:31 pm
Re: Get Latest Post?
I finally got around to this and, no. You did not make that function that way. You did make a get_posts function but that just got all the blog posts and summaries
Re: Get Latest Post?
Maybe it was in the Pagination video then ? Either way you could create a new function
function get_latest_post(){ $sql = "SELECT `things` FROM `table` ORDER BY `post_id` DESC LIMIT 0, 1"; /* More things go here. */ }