I am using get_post() to call a single Wordpress post using it's post ID. I have successfully managed to pull the content / title of the post but would like to also pull custom fields also.
The code below is how I declare custom fields in a standard wp_query:
$customField = (get_post_meta($post->ID, "_mcf_customField", true));
And my get_post code below:
$my_id = 401491; $post_id = get_post($my_id); $customField = get_post_meta($post_id, "_mcf_customField", true); // I do not think this is correct $content = $post_id ->post_content; echo $content; echo $customField; // No output
I believe the customField variable above is declared incorrectly, cannot seem to find anything in the Codex that sheds any light though. Does anyone have experience using Custom fields with get_post?