1
votes

I have looked everywhere and am not finding the answer I'm looking for.

Basically I want to access information from a post and display it on my front page.

I'm using a plugin called Advanced Custom Fields to organize my content for each post.

I can retrieve the post title like this.

$post_id = 148;
$queried_post = get_post($post_id);
?>
<h2><?php echo $queried_post->post_title; ?></h2>
<?php echo $queried_post->field_4f2af94aa1371; ?>

But I can not access the value of the custom fields. Can anyone help me?

1
What do you get when you var_dump($queried_post)? - David Xia

1 Answers

0
votes

Use the get_post_meta function

<?php echo get_post_meta($post_id, 'CUSTOM_FIELD_NAME', TRUE ); ?>
  • first param: post ID
  • second param: key (name of the meta value)
  • third param: true if you want a single value (instead of array)

For more information; http://codex.wordpress.org/Function_Reference/get_post_meta