Troubled by post->ID in get_post_meta (Custom Fields)
-
I have the following problem which it’s easy to solve applying simple knowledge of PHP, which I haven’t.
I can call a custom field in my theme code with the following php code:
< ?php $key="Fecha"; echo get_post_meta($post- >ID, $key, true); ? >
But if I insert the same code in a post, it doesn’t work. When the post is published, it appears as text everything that is displayed after “->”: ID, $ key, true);?>
Therefore, I assume that the “->” is acting as code closing command.
I’ve tried other alternatives: “- >”, ” ->” and so on. But the outcoming is the same.
I also tried declaring the variable $postid before, but no success either:
< ?php $postid = get_the_ID(); $key="Fecha"; echo get_post_meta($postid, $key, true); ? >
Any help will be welcomed
- The topic ‘Troubled by post->ID in get_post_meta (Custom Fields)’ is closed to new replies.