0
votes

In the main content area of a wordpress page I'm using a php include to add in some script.

In the include script I can display the custom field values using the_meta().

However I need to use the value from a specific custom field, so I tried this

get_post_meta(post->ID, 'myfield', true);

Unfortunately the post->ID can not be found.

How can get the value of a custom field from within a script added by a php include?

1

1 Answers

0
votes

If you're withing the loop ( meaning you inlude the file in you're wordpress post loop ) you could use this :

$postID = get_the_ID();
$metaValues = get_post_meta($postID, 'myfield', true);