How to retrieve custom field types for all posts in WordPress/PHP?

Custom fields are saved as “post meta” which is stored in wp_postmeta. To retrieve them, you use the get_post_meta() function as follows: $value = get_post_meta( $post_id, $meta_key, $single ); $single will almost always be set to true if you’re working string data. Unfortunately, it defaults as false, so if you’re retrieving the data as a … Read more

get_post_meta not working inside loop

There is nothing ‘improper’ about the second block of code. Its just written for debugging purposes. The key difference is that that second block used get_the_ID(). Try that. add_action (‘genesis_before_post_content’, ‘gteh_tagline’); function gteh_tagline() { $meta = get_post_meta(get_the_ID(), $field[‘dbt_text’], true); echo $meta; } Or try to pull in $post with global. add_action (‘genesis_before_post_content’, ‘gteh_tagline’); function gteh_tagline() … Read more