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
- 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
- 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
- Sorting a query by custom field date
- How to sort CPT by custom meta value (date), and return posts month by month
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Comparing timestamps in meta query doesn’t work
- Conditional to modify query results
- wp_query to find posts by year and month
- Create a random unique 6 digit number as custom field for custom post type
- how to interconnect custom post types?
- Get all Posts If has same custom field values in Posts
- 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
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Meta Key Value in current-user-only loop
- wp_query check if integer exists in custom field’s array
- How to implement a Google map store locator
- How can I get the number of custom post type posts that have a specific attachment image set?
- 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
- Including metaboxes from custom post types in global search — continued
- 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
- Possible to filter custom post type with multiple meta data?
- Importing Data from a Non-WordPress database, into WP
- Query based on custom fields start and end date
- Check if post with same meta value exists
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- WP Query ‘posts_per_page’
- delete_post_meta() for whole CPT / multiple posts?
- Getting a custom post’s custom field based on another custom post’s custom field select
- WP_Query orderby not work with meta_key
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- $post->post_meta not pulling any post in wordpress/php
- WP_Query of custom post type sorted by meta_key has unexpected results
- Returning a custom content types with meta values
- copy images from custom field to another custom field
- How to show custom field on specific custom post type posts only when filled
- Custom Post type loop with ACF not displaying properly
- Cannot obtain custom meta information
- How can I output WPAlchemy repeating fields meta values in my page template?
- 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
- Cache issue with WP_Query and custom field filtering
- Empty meta-box returns publishdate if no value is set?
- Filter search posts by post meta?
- 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
- Alike Shortcode using in Custom Shortcode
- Sort custom post column by generated value?
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Use WP_query to match post types based on custom field values
- Filter posts by their related field’s custom field
- 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 a Custom Post Type using SELECT that has ACF fields to compare dates
- How to get post by meta value
- Post Filtered by Custom Field Value
- How do I get all authors posts of a custom post type outside loop
- 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
- How do I extract the contents of a CPT’s custom field for all posts?
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- 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?
- Calling specific page with wp query
- How to stop wp_query searching pages as well as the specified CPT
- WP_Query and two custom fields returns no posts
- Storing/querying custom date data
- 404 on Pages for Custom Post Type & Query_Posts
- 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?