When you set the third parameter of get_post_meta
to true, the function returns a string, as you can read in the codex. So:
$arr = get_post_meta($post->ID, 'tab_details', true);
Makes $arr
be a string and a string is not a valid argument for a PHP foreach
loop and that is waht the error message says.
Instead, if you set the third parameter to false
or leave it blank, you will get an array with all values for the spècified meta_key (or an empty array if no values are found):
$arr = get_post_meta($post->ID, 'tab_details');
//Now $arr is an array
foreach($arr as $part){....}
Related Posts:
- Custom shortcode being executed when saving page in wp-admin
- Change appearance of shortcode text inside editor
- Shortcode outputs at the top of the_content
- Shortcode output always showing at top of page
- How to detect if a Shortcode is being called on a page?
- shortcode inside another shortcode
- How can I just get content inside a shortcode or just outside
- Need MySQL Query or WP-CLI command to updates old URLs in Shortcodes [closed]
- WordPress core responsive video not working with shortcode
- WordPress gallery ‘post_gallery’ filter doesn’t work with feeds?
- shortcode to create dynamic dropdown box form shortcode attributes
- Ajax not returning anything on form submit
- How do I add my own custom shortcodes?
- Can’t seem to get [shortcode]s to work
- nested Shortcode doesn’t work
- Simple contact form with field validation
- Slow page loading when using a simple shortcode on the same page multiple times
- TinyMCE get selected text and underlying HTML
- Remove and restore one shortcode
- Rewriting WordPress Gallery Shortcode with Bootstrap Carousel
- Using do_shortcode with variables?
- Using ACF field in do_shortcode()
- Display content from another site page using a shortcode
- Remove hyperlink on gallery shortcode
- Shortcode with no attribute but has value
- Remove wpautop from specific shortcodes only
- Combining similar shortcode functions?
- Creating a shortcode based on users preferences
- Get a post’s thumbnail url or display default image in shortcode
- Shortcode adding plugin output before post, instead of inline [duplicate]
- Convert HTML Script to Shortcode [closed]
- How to build a shortcode which can insert a query string into a DB table
- What is the Correct way to pass parameters in function
- Shortcode – Getting Categories appears on top of website
- Visual Composer integration [closed]
- How to Modify WordPress Default Image Gallery Shortcode
- Passing html tags as shortcode parameters
- Registration Form Shortcode
- Button Shortcode
- Shortcodes in excerpts returning empty string
- Conditionally Loading JavaScript/CSS for Shortcodes
- Placing tags on wordpress visual editor using shortcodes
- Using Variables in Shortcodes
- Default Attributes in Shortcode Not Working
- Replacement for gallery_shortcode function not taking all attributes
- Shortcode syntax errors
- how can i pass this attribute in this shortcode?
- How to add a same div on every page
- WordPress Shortcode / Only works in classic editor, gutenberg error / invalid json response
- Display a form partially with a shortcode
- Do shortcode in template file
- Modifying the wordpress login page and then referencing it with a shortcode problem
- Pass instance number to shortcode child
- How to make shortcode which returns HTML?
- Different ID in every shortcode
- Unique ID for WordPress shortcodes when used more than once on a page?
- Which wordpress function is the caption shortcode linked to?
- How to find out what handler is registered to a shortcode
- Shortcode strips formatting and returns at content top
- do_shortcode within a shortcode
- How to display NextGEN gallery in templates?
- Build Clickable Link Using Multiple Attributes
- Using Shorcodes in Sharing Preview and Notifications Title from Post Title
- Is the WP audio shortcode still relevant?
- Disable wpautop on Shortcode attributes
- remove shortcode pagination for specific url referrer
- Third-Party API – PHP Fatal Errors Paired with http_request_failed / cURL error 28
- If statement shortcode
- Using within a shortcode
- Shortcode not working when I output data from wpdb html table row
- update_metadata() appends shortcode data for every page refresh
- How do I point bloginfo(‘stylesheet_directory’) to my parent theme?
- Gallery shortcode is empty but magically creates a gallery
- How to avoid one code multiple times instead do that through some function? Shortcode, but I think shortcode is not used in main theme’s core files?
- Shortcode appeared twice on page, one time before content, one time where it’s really called
- How to list child pages with excerpts, e.g. [child-pages depth=”1″ excerpt=”1″]
- Add a shortcode in woo-function.php
- Get current category and place it in shortcode
- Woocommerce products shortcode specific order
- Modify Blog Module layout in Child theme
- Video shortcode outside WordPress not working with IE and mediaelement’s Flash fallback
- Display title of child pages in shortcode
- Output html source tags inside shortcode
- How can I define the output of shortcode attribute value?
- Using shortcodes that wrap around code
- Shortcode for Admin Theme Option?
- What is the best way to include a template file within a shortcode?
- What makes a placeholder resizable in Tinymce?
- Shortcode templates
- Create plugin/function to catch XML-data via Shortcode
- Why My slider shortcode display above header
- Does anyone recognize shortcode ig_special_heading?
- How to scroll to a shortcode-generated anchor
- add post type pram to wp shortcode
- Shortcode conversion to hrml when post is published
- Shotcode error on functions
- Shortcode for displaying the user’s first name?
- Can I prevent wordpress adding and tags to autoembeds
- Shortcode – Display inline icon before text [closed]
- How to use multiple values in “Shortcode”? [closed]