The following code works brilliantly for retrieving certain pages, but I can’t get it to retrieve POSTS by name. I’d like exactly the same code, but to retrieve posts rather than pages. Any help appreciated.
<?php
function get_my_content($page) {
$my_id = $page;
$post_id = get_post($my_id, ARRAY_A);
$content = $post_id['post_content'];
return $content;
}
?>
<div id='test'>
<?php
$page = get_page_by_title('testpage');
echo get_my_content($page);
?>
</div>
As per docs you only need to specify different post type to make it work:
Using that earlier question I was referring to, you could do something like this:
Does this post over on WordPress.org help you? http://wordpress.org/support/topic/get-posts-based-on-page-title