The solution you used seems correct. But if you still want to know alternatives, here it is:
$varname = get_post_meta($post_id, 'fieldname', true);
echo $varname;
$varname
will be an array if the last parameter is false
and will be the value of metadata field if the last parameter is true
.
You can use the_field()
as well which works similar to get_field()
you used.
Related Posts:
- get_post_custom stripping styling issue
- Guest Author – How to display posts on /author/ archive page
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Saving Post Data in Another Database
- WP_Query custom field pass the post id
- If custom field is empty, use one from a previous post
- Auto populate custom fields by post date
- ACF Relationship – Get Parent’s Post Object
- How to make a local “scroll to ID” on post?
- How to detect if an ACF custom-field is really in use?
- How set featured posts using checkbox in post edit screen?
- Add a checkbox to post screen that adds a class to the title
- Convert custom fields to post categories
- Update all posts automatically when using post_meta
- I am trying to create a simple frontend form for posting
- HTML code in Custom field
- How to show posts rank based on custom field value
- Add custom field to all posts in specific category
- meta_box or custom_field as a second tinymce post-instance?
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Create A Metabox For A Custom Field
- Change post format using custom field
- Populating a page with content from post custom fields
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- How can I make existing custom fields easier to edit/add in my theme?
- Add custom fields to post programmatically
- Autoremove empty custom fields
- How to add a custom field after wp post
- Custom fields on a virtual page
- What Is meta_id In wp_postmeta?
- Get a custom field of all posts on current blog page
- Only display posts after current date
- Global $post not working in OOP function WordPress
- How can I get a post field value using javascript?
- Automatic value for custom fields for posts
- How can I sort posts by the date and a custom meta field?
- How to display Common posts from specific Tag & Category with Shortcode
- Check if checkbox is marked on publish/update post
- Automatically add custom fields value to wordpress post
- MySql query to get posts with all meta and terms
- Query Posts With Over 1000 Views
- Hooking into the post editing screen for an existing page only
- Redirect to another page using contact form 7? [closed]
- How to rate a post from Admin Side / Manually?
- Customize rel=canonical tag for single blog post
- Get post ID from a link
- Create a list of posts with topic headdings
- Add field to user meta table in database when link is clicked
- Hide custom metabox value from custom fields
- Get post meta retrieving wrong value
- ACF to select posts not displaying on blog page
- if in category but only with post meta
- Getting property of non-object when looping through post objects from ACF
- Update post meta within save_post action
- Add two custom fields as a default to the “new post” page.
- After ajax image is outside the “ tag
- How to display post list in a table layout (multiple queries in single loop)
- Edit custom fields in posts list
- Why my meta boxes won’t show in front post page?
- Display content between two dates?
- Will multiple category descriptions effect my search engine optimization?
- Automate post update for all posts?
- What snippet do I need to type to show my ACF field show up on my theme?
- Override WordPress core post-template.php block template
- ACF flexible content block not showing on live site (works locally)
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Post picker custom field on page
- Post meta not working
- ACF date picker to trigger category change
- How to work with posts and sub posts?
- Run a function when a custom post is update?
- Adding an option to post editor to show a site disclaimer or message
- Template with ACF and Pagebuilder
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- How do you update post date (year only) in a separate custom field?
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- Assign a day of the week to post, e.g: Assign Monday to post and have it only appear when the day is Monday
- How do I display posts ordered by a date custom field?
- Creating Ordered Query using Meta_key
- WordPress Request Post All Post ID in a Loop? [closed]
- Extracting a TLD from the content and assign to custom field
- How can I set and update the the_date according to a custom field of the post
- How to retrieve a post by inputing the url in a custom field and displaying it on an options page
- Custom fields in normal posts
- WP Query between posts custom fields [duplicate]
- Using Post ID and Page ID in same function
- Order posts by separate menu order for different sub-categories
- How to custom sort-out editing-panel fields?
- Delete old post with new post
- How can I create a menu items from meta box based on users input
- get_post_meta property of non object
- Home page: using custom fields for posts and pages
- How would I attach media/images to a post based on a ID stored in a each post’s custom field
- How do I insert a custom field in a user submitted post?
- How to Do Custom Fields to Output a Definition List
- How do I show the post title if an advanced custom field hasn’t been used?
- Custom post order returning posts from other categories
- Read more opens attachment
- How to make internal links creating plugin to respect ACF?
- Image inside the content is replaced with featured image from my older post