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
- Query all posts where a meta key does not exist
- what is the correct way to compare dates in a WP query_posts meta_query
- 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
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Search multiple custom fields by using meta_query
- How do I Paginate Search Results for Custom Post Types?
- WP_Meta_Query object with conditionals
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- delete duplicate meta_value with same post_id
- Search CPT Title AND Meta
- updating one custom meta field only
- Cache issue with WP_Query and custom field filtering
- 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?
- WP query_posts group by meta field related
- Custom fields for post or terms which don’t update on post update
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- Custom Form / Search with Custom Post Type Data
- After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
- Create if else for post types in WP_Query ‘post__in’ values
- WP Query from two Custom Post type fields as statement
- 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 to keep custom post type related information
- 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 to sort by multiple values in a nested WP_Query
- 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
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- 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
- Where is get_post_meta value located?
- 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
- Sort custom post archives by a meta value from a different custom post type?
- 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
- Meta_Query refuses to return results
- Linking posts together with Advanced Custom Fields “both ways”
- Add more custom fields when creating a new custom post type
- How do I extract the contents of a CPT’s custom field for all posts?
- 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
- How to get post meta for custom post type and taxonomy
- get_post_meta for Custom Post Type ( CPT )
- Query events post type after current date and timezone
- Delete custom post type metadata without deleting the post in admin area
- How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
- How to add post reference field to a plugin?
- Calling specific page with wp query
- WordPress custom post type
- How to stop wp_query searching pages as well as the specified CPT
- Selecting posts older than the current Unix epoch timestamp
- Custom Post Type meta oembed html output resulting in WSoD
- Values inside a custom field to determine which category posts to display
- WP_Query and two custom fields returns no posts
- WP_Query get posts where post_name is empty
- Storing/querying custom date data
- Advanced search form with filters for custom taxonomies and custom fields
- Query recent posts by author
- 404 on Pages for Custom Post Type & Query_Posts
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Filter Custom post type by another Custom post type
- Show Posts in Vertical Tabs with Scrollbar
- How to show all posts of specific custom post type with their custom fields values?
- Display a list of posts whose meta field values are equal to the ID of the post being viewed?
- Check for custom field value in different post type than current one and do something
- 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?
- Query order by a numeric ACF field
- WP_Query not using relation key as expected and not producing any results
- Quering a post object based on another related post object
- Use Custom Field to Display Post Loop