get_field is a replacement for get_post_meta you have to use only it:
$my_post_meta = get_field('album_image', 556);
if ( ! empty($my_post_meta) ) {
// use the image
}
If you don’t know the ID and want retrieve the post meta via post name, you have to use WP_Query or get_posts to ge the post via slug:
$posts = get_posts('post_name=here-the-post-name&post_type=release');
$mypost = ( ! empty($posts) ) ? array_pop($posts) : false;
$my_post_meta = $mypost ? get_field('album_image', $mypost->ID) : '';
if ( ! empty($my_post_meta) ) {
// use the image
}
Related Posts:
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Querying meta values within an array
- Advanced search form with filters for custom taxonomies and custom fields
- Multiple orderby values in WP_Query
- Meta query with boolean true/false value
- Get post with multiple meta keys and value
- Custom field values deleted when trashing custom post type
- How to get all custom fields of any post type
- Search multiple custom fields by using meta_query
- How do I Paginate Search Results for Custom Post Types?
- Sorting a query by custom field date
- Filtering a WP Query result
- How to sort CPT by custom meta value (date), and return posts month by month
- How Do I Use WP_Query to Run This Database Query as Search Result?
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Comparing timestamps in meta query doesn’t work
- WP Query group/order by category name
- wp_query to find posts by year and month
- How to dynamically attach pictures to a carousel
- how to interconnect custom post types?
- WordPress Orderby Numeric Value Not Working
- List all images from a single post meta value
- Including Custom Meta with posts_where query
- orderby in custom WP Query does not work
- WP_Query: include custom post type only with specific meta value
- WordPress custom loop filter by meta_key and value with serialize data
- Meta Key Value in current-user-only loop
- How to implement a Google map store locator
- Posting to a Custom Post Type from front end – user generated content
- Update Post Meta for a logged in user
- Problem querying Custom post type by custom fields
- Orderby CPT custom fields not working
- Two Custom Post Types Many to Many Relationship
- get_post_meta not working on publishing
- Query custom post type with ACF Date
- Query Multiple Custom Posts by Custom Fields
- WordPress request fiter order by related post’s post_title
- Order Custom Post Type by Custom Field Value
- First custom field value (out of several) displayed twice after query
- Possible to filter custom post type with multiple meta data?
- Custom fields for custom post type
- create custom meta box with default value
- delete_post_meta() for whole CPT / multiple posts?
- $post->post_meta not pulling any post in wordpress/php
- WP_Query of custom post type sorted by meta_key has unexpected results
- Cannot obtain custom meta information
- Group by custom field value (start and end times)
- How to call a post’s metadata in shortcode.php?
- WP_Meta_Query object with conditionals
- delete duplicate meta_value with same post_id
- Search CPT Title AND Meta
- updating one custom meta field only
- Add a class to post_class if more than one post shares same meta_value_num
- Add a meta field to the list of results for a custom post type
- Empty meta-box returns publishdate if no value is set?
- How do I list a custom field and custom taxonomies for each result in a loop?
- Filter search posts by post meta?
- Custom fields for post or terms which don’t update on post update
- Alike Shortcode using in Custom Shortcode
- Query custom post type that has a serialized relational advanced custom field value
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- WP_Query get always custom post_type for first
- Sort custom post column by generated value?
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How can I query and sort custom-post type using WP_Query
- Use WP_query to match post types based on custom field values
- Filter posts by their related field’s custom field
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Show posts from WP Custom Post Type selected from a field in a metabox
- Query custom post type and custom field by URL parameters
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- meta query multiple values for the same key
- How to get post by meta value
- Custom post types – meta_query: search lesson which starts sooner
- Post Filtered by Custom Field Value
- How do I get all authors posts of a custom post type outside loop
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
- sorting in wp query based on custom field value
- Linking posts together with Advanced Custom Fields “both ways”
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- How to get Current week and current date record wp query
- Error in WP Query. If variable is empty it is displaying previous post value
- get_post_meta for Custom Post Type ( CPT )
- How to add post reference field to a plugin?
- WordPress custom post type
- Custom Post Type meta oembed html output resulting in WSoD
- WP_Query and two custom fields returns no posts
- Storing/querying custom date data
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- How to show all posts of specific custom post type with their custom fields values?
- querying to custom field over ACF REST API
- Display ACF object field data using Elementor Custom Query
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Sort CPT by taxonomy AND THEN by custom field
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- Quering a post object based on another related post object