Earlier today I was talking about how I haven't blogged in a little while, I feel ashamed at the truth of it. So as I was problem solving with a colleague tonight I spotted the opportunity for a nice helpful quick and dirty little Wordpress post.
Some times the case may arise when you have set a static page as your blog page and wish to add a small blurb above your post loop, or even some custom meta to control a few images in your layout theme? Now it's a piece of cake just to add them into your theme. But, point is, the client's not going to dive into that file, nor do we want them too. So what we want to be able to do is, spew out some content, and then spew out the loop of blogs.
For those of you seeking the answer, or an answer I should say. You will most likely have been frustrated for a little while that $posts->ID refers to the post loop and by default wordpress has it's wp_query instance set to your post loop settings.
It's easy enough to manually enter the id and grab the page however, we want to do it dynamically. so after a little digging, I came up with this solution.
This pretty much gives you all the control you could ever need, but just incase your worried, here's the std Object output from an example.
stdClass Object ( [ID] => 15 [post_author] => 1 [post_date] => 2011-08-10 09:22:40 [post_date_gmt] => 2011-08-10 09:22:40 [post_content] => Just going to be testing whether this is working or not. [post_title] => Blog [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => blog [to_ping] => [pinged] => [post_modified] => 2011-10-20 21:39:14 [post_modified_gmt] => 2011-10-20 21:39:14 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost:8888/bytewire/?page_id=15 [menu_order] => 0 [post_type] => page [post_mime_type] => [comment_count] => 0 [ancestors] => Array ( ) [filter] => raw )
Even without this, we can grab such things as meta data.
=get_post_meta($page_id, 'sliderheading', true);?>
I'm still looking for a solution that solves category, archive and deeper browsing though mind you.