i am not sure that this is place you should change the shortcode
This code retrieves several values and not one..
as i understand it you are looking to get one value back right ?
that’s much simpler and doesen’t require the use of “foreach”
you simply put this in the desired location
<?php echo get_post_meta($post->ID, 'restaurants', true); ?>
EDIT 1
To get a custom field value inside the loop:
$key="mykey";
echo get_post_meta($post->ID, $key, true);
.
to get a custom field value outside the loop:
global $wp_query;
$postid = $wp_query->post->ID;
$key="mykey";
echo get_post_meta($postid, $key, true);
- in both case the key is the custom field name…
Related Posts:
- How to rename a custom field?
- How can I make wp-pagenavi work on a custom query built upon a form submission? [closed]
- Meta Query with AND & OR?
- Plugin similar to Taxonomy Drill-Down for custom fields?
- How do I query for a post by custom field?
- Count how many posts have a custom field set
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- sort search results by custom fields using dropdown
- How can I sort homepage by a meta value?
- Loop to display random posts only if a custom field matches category
- Conditional custom field query
- Display only past events on that page using Visual Composer Grid Bulider
- Custom Field Create Bulk via SQL Query
- Create Pop-Up Box with Custom Field Content Inside the Loop
- query usermeta from custom field
- Is there any way to get all meta and standard columns for any WordPress object after searching based on meta key and value
- Order RSS content by an advanced custom field value
- Alter main archive, to show posts with meta as last
- Trying to reorder posts by custom field
- Limits, not all post are showen when querying for posts by view count
- Why orderbyb meta_value_num won’t affect the generated SQL Query order?
- Get post ids sorted by meta_key
- pre_get_posts : only get posts by wp_usermeta value
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- How to query an out put value?
- List custom queried terms in the edit-tags.php?taxonomy page
- Modify date query by URL parameter using pre_get_posts and $_GET
- Loop through incrementing custom fields
- Custom search SQL Query to add custom field in result
- The best way to collision check in WP
- How to exclude custom fields from search queries?
- WP_Query () using taxonomy, custom post types
- How to query for posts with either one or another custom field
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- Custom Query: query by post custom meta data
- Get array of posts based on custom field values
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- How to query posts by month based on date custom field?
- Custom Field Date Problem
- Compare ACF date field (if exists) and post date and order DESC
- Problem with revisions only returning four results
- Search & column order by meta value in admin
- Dynamically populate query source in Elementor post widget
- searching by keywords in post’s metas or pagination links problem
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- Create custom query for search?
- query specific posts according their custom fields, using sql SELECT
- Meta_query not filtering posts
- Get multiple posts with some custom fields efficient
- How to add a prefix to existing custom fields over MYSQL query?
- Complex WP_Query Using Post Date And Post Meta
- How to check if custom field exists in this widget query
- Only show content slideshow if “slideshow” custom field exists
- How to display search query as formatted text?
- WP_Query – Order results by meta value
- Custom query with orderby meta_value of custom field
- How to enable revisions for post meta data?
- Including custom fields in search?
- Sort posts by custom field numeric value using dropdown
- How to position a custom field before the editor
- How can I display all values of a custom field from posts with a certain value of another custom field or from certain post types?
- How to add upload field in a custom taxonomy?
- Display thumbnail from custom field
- Bulk move (or copy) from a custom field to the post content?
- Getting Custom Field data from a page hierarchy
- limit amount of photos uploaded per cpt post
- Problem with adding exta field in metabox in custom post type
- Add WYSIWYG to Image Description field
- Calling custom profile fields?
- Create Multiple File Upload Metabox in WordPress
- WP_User_Query pulling ACF to loop
- how to put a custom field value in variable
- How can I output a list of values for a custom field, and posts with those values?
- Add additional ‘description’ field for defined roles / role metadata?
- Where does this field get its value?
- Get all the posts where meta field with multiple choice has several values checked
- Warn user that data may be lost for custom pages
- Display MP3 as media using an URL from a custom field
- Update post meta custom field using block editor
- If I update WordPress my custom data will be deleted from the wp_users table?
- Get emails from users by custom field SQL
- Convert all dates stored in custom field
- Why am I getting a “Call to member function format() on a non-object” error?
- Custom Query Fields – Altering Meta Value
- Adding re-type email and check it if the email match
- excluding posts by an ACF field in pagination
- Exclude URL’s from sanitize_html_classes
- How to add a post’s view count into the WordPress API response
- How to get all wp_posts in wordpress fetched from database
- automatically add custom fields to post title
- Custom Fields Permalink Plugin not observing hyphens
- will wp_insert_post write a new custom field to the database?
- How to repeate custom field group with bulk image field
- Extra text’n’image field in a page
- Get first URL from custom field, download and set as featured image on post publish
- How to add an option to admin to add image that could be used as header?
- How to query posts that have certain post meta keys, and sort by meta key and/or value
- Foreach giving one too many list items, how can I remove the last empty line?
- Add custom fields to specific menus
- How to apply Local Business Google Schema dynamically on a Custom Post single template?