Not 100% sure I understand the question or problem, but this ought to work, I think:
add_action( 'the_post', 'output_my_custom_field');
function output_my_custom_field( $post_object ) {
$post_id = $post_object->ID;
// why the conditional (and redundant !empty) ?
// if ( !empty($post_id) ) ) {
$my_custom_field = get_post_meta( $post_id, 'my_custom_field', true );
var_dump($my_custom_field);
// see above
// }
}
Related Posts:
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- Meta query with boolean true/false value
- Custom field values deleted when trashing custom post type
- Custom Post type – how to get checkbox to update meta field to null
- How do I Paginate Search Results for Custom Post Types?
- Ordering posts having multiple post-meta date fields
- How do I remove all the metaboxes for a custom post type?
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
- Grossly inefficient wordpress loops!
- How Do I Use WP_Query to Run This Database Query as Search Result?
- WordPress Admin Panel search posts with custom post meta values along with title
- Custom post type category not displaying in custom post type
- How to make custom post meta wp_editor translatable?
- How to add multiple featured image in meta box in post editor?
- update_post_meta() whenever custom post type is updated
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- How to best delete orphan wp_postmeta
- Count posts with specific term_meta
- Custom search for custom post meta with pre_get_posts interferes with WP search
- WordPress Orderby Numeric Value Not Working
- Replace title column in post list with post meta value
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- List all images from a single post meta value
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Insert Multiple Post with Same Publish Button
- Undefined Variable – Custom Post Type Meta
- Ordering posts in Search & taxonomy by post_meta
- Post image in WordPress not appearing on home page
- changing meta value and meta key of price field
- Posting to a Custom Post Type from front end – user generated content
- Update Post Meta for a logged in user
- Getting meta in editor plugin, and event triggering issue
- Restrict Access to Posts based on Custom User and Post Meta Data
- Metabox not show in categories custom post type cmb2
- Can’t publish custom post type – “You are not allowed to edit this post.”
- Filter date from post meta when date is in string format
- Get only used meta_values
- Is there a way to exclude posts based on meta_values?
- Submitting Custom Post Types with custom fields from Front-end form
- Get $post->ID from a URL
- Displaying a div from an assigned meta_value when on a page
- Setting Post Title via Meta Data returns Auto-draft
- Filter posts by tax (dropdown) and meta value
- Publish and save specific postmeta to a filtered post_type
- Custom post type suddenly stoped working after WordPress 5 update
- Batch Extract Date from post title and put into ACF custom field
- How to show custom field on specific custom post type posts only when filled
- How to handle this specific case of custom post type?
- Save CTP post meta different values each day without overwriting previous values
- Problem with adding custom post type meta to header by plugin
- Meta box data is saved but NOT displayed in the meta box text field. Why?
- Echo custom post meta from options array
- Value of post meta dropdown is not showing in WordPress
- WP_Meta_Query object with conditionals
- Trying to write shortcode with get_post_meta but isn’t working
- Sanitaizing Select Optin For Custom Post Type Metabox in WP
- HM CMB: Post Select Field for CPT ID
- Getting WordPress to store 0 values for custom post type meta
- updating one custom meta field only
- Problem Saving Custom Post Type Meta Values
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Get_post_custom not fetching value from array wordpress
- Save data is post using php front end
- Creating a custom post type upon registration for a specific user role
- How to sort by multiple values in a nested WP_Query
- Show posts from WP Custom Post Type selected from a field in a metabox
- Where is get_post_meta value located?
- How do I create a customised table list of a custom post type (in the admin area)?
- Unknown Post Meta Records
- Get Previous Post based on Custom Field Name, for Custom Post Type
- Saving custom post types post_meta over REST-API fails
- add action save post type and update post meta woocommerce
- get_post_meta not working with variable as a post_id for dynamically get the postid
- How to save post_status using action save_post?
- Custom post meta box as a sub form
- Metaboxes in Loop
- Add more custom fields when creating a new custom post type
- Custom meta box data not saving
- Stripe multiple transactions
- Collect custom post in a calendar
- Storing data in a multidimensional array from dynamically generated foreach loop
- Edit is changing my custom’s post type parent id
- Disable Facebook Comments Automatically On CPT
- Problem with ‘save_post’ hook not running
- Howto: use existing post_meta as options for a different metabox (checkboxes or list)
- Values inside a custom field to determine which category posts to display
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- How to rewrite CPT-Permalinks the correct way (incorporating meta-box-data)?
- Change the contents of a dropdown through the admin panel?
- Advanced search form with filters for custom taxonomies and custom fields
- Top 30 Songs using Custom Post Type
- Advice Needed for Post Meta Database Efficiency
- fetch meta fields inside a widget
- Querying meta values within an array
- Custom post type – update_meta not working
- why get_post_meta is returning 0?
- Save post_parent in a custom post type
- Use a Variable in update_post_meta as the $meta_key
- Update an existing post in a custom post type