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 to protect pages with double authentication: password + email (in custom field)
- How set featured posts using checkbox in post edit screen?
- Add a checkbox to post screen that adds a class to the title
- Custom Field in Featured image for A particular post
- 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
- Prevent duplicate posts in wp_insert_post using custom fields
- HTML code in Custom field
- Better post meta efficiency?
- How to show posts rank based on custom field value
- Add custom field to all posts in specific category
- Adding a Nav menu to post admin
- 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
- Paragraphs removed when using get_post_custom()?
- Change post format using custom field
- get post id in while loops outputting page id
- Populating a page with content from post custom fields
- How to change what the post creation page looks like?
- 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
- Add custom field automatically (add_post_meta) with value based on number of words of article
- 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
- Understanding and using metaboxes in posts
- Duplicating Table of Contents for Paginated Post
- WP_Query orderby not working with meta_value_num and menu_order
- 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
- Query values from a Post Object Repeater [closed]
- Is there a way to notify specific users when new posts are published to specific pages?
- MySql query to get posts with all meta and terms
- Categories list into registration form
- Add a custom meta box in the post options that loads some html code in the header
- Query Posts With Over 1000 Views
- Cannot retrieve a custom RSS field from posts
- Saving custom fields to a custom taxonomy
- Hooking into the post editing screen for an existing page only
- Query Posts by Custom Field
- 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
- How to I retrieve the ID from the Posts page?
- 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
- Edit multiple custom post types while saving a new or edited post
- 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
- Output Post with ACF Fields into other Post
- Add hero image to home page (blog format) via the dashboard
- 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
- Add multiple meta keys to a post at once
- saving/reading custom field value does not work – no value gets POSTed
- Why my meta boxes won’t show in front post page?
- Adding external field to my post form (admin side) and to post show (frontend side)
- How To Use Custom Fields With .mp3 Links
- how can display a post on home screen without images
- 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?
- How to save template data into wp_post table (post_content column)
- 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
- Custom Fields – How to get the list of a specific active widget each time it rendered
- search form for custom fields