Okay, I think that I’ve sorted this myself by looking again at the isset check. Instead of
if ( ! empty( $connections ) ) {
I’ve put:
if ( isset( $connections[0]['gwl_collection_item_name_connection_related_post'] ) ) {
and so far this seems to be working. (I think the issue arises because the CMB2 group saves an empty array in the meta_value column, so $connections isn’t empty/ is set, and because the array doesn’t have a value for the post id, it then pulls in the id of the initial post – but I’m not sure if my understanding of this is correct)
Related Posts:
- How to add meta box to plugin admin page?
- Add custom meta box on Post page
- Validation Function for URL in plugin
- Creating Custom Meta Boxes on Plugin Option Page
- How to attach Links into page/post or custom post type?
- Add custom buttons with custom actions in Edit Post screen in WordPress?
- Best Way to Remove WordPress Meta Box based on Post Status
- Plugin “Meta Box”: Implementing meta boxes in custom post type
- How WordPress autosave can save plugin fields?
- How can I filter the contents of a metafield before it’s displayed in the admin?
- Admin Dashboard with Custom Tab for Client
- Security checking in meta_box save is reluctant?
- Advanced Custom Fields
- RW Meta Box ,Problem setting post title
- dynamically generating plugin syntax
- Not able to complete meta box save function and sanitization/validation
- Correct way to make meta box with more than one meta field secure
- get_post_type on post.php
- All of my custom posttypes are 404’ing
- Save / Show multi line text in metabox
- PHP basics help in WP context – remove a class/function?
- How to remove plugin metaboxes from edit.php
- How can I make my metabox appear?
- How to inform the user that the save was not successful?
- Show meta box only when post is being published first time
- Retrieving Meta from Image Attachment
- WordPress metaboxes – textfield suggestion automatically populated
- Why are my queries interfering with the global post variable?
- Finding the screen id of a page generated with add_menu_page
- Date format – Meta Box plugin
- Meta Box by Rilwis, Load metabox on all page templates EXCEPT the homepage
- Adding custom meta boxes to specified custom post type
- Access post title from custom meta box on title change
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- add_meta_box creating default form field types
- Should meta boxes for specific pages be save in their own plugins?
- WordPress meta-box and checkbox-list
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- Custom Meta box change size
- Preset custom fields
- submit two file input fields in the same form
- WordPress default post categories meta box widget
- How to get checkbox by default true in metabox?
- How to pass multiple custom fields as shortcode’s parameters
- CMB2 Output Select Box Chosen Option
- Add Cancel Button to a Custom Meta Box
- WordPress CPT Url metabox collection
- Add_Meta_box to custom page (formidable edit post)
- why my wordpress dont have toolbar like, plugin, themes and other?
- My own metabox checkbox plugin only saves the last value I’ve checked
- Do something with thumbnail image on post publish
- How can I remove this sidebar from my Search Results page?
- Add custom field for users
- Alter add_meta_box
- Displaying image from a repeatable group
- How to add jquery to my custom post type wp plugin
- How to get rid of error message of custom metabox in dashboard when moving out of edit page?
- Metabox Data not saving
- Custom plugin breaks css.php on Multisite
- Advanced Custom Field User Help URL
- Problem for recover and save metaboxes
- How can i do custom author list?
- Meta Box plugin image_advanced not showing up on frontend
- How to change data format in custom meta box field [closed]
- iframe not showing on frontend when using a CMB2 field
- Problems with file_exists() with metabox plugin in WordPress
- Meta box not displaying on the plugin page
- add_meta_box showing blank screen in my page
- Remove WordPress Toolbar buttons
- Adding an admin page – OOP approach not working
- How can I pass a variable to wp_ajax action?
- How to call a function in wordpress plugin from another site
- How do I make images clickable so as to enlarge them using lightbox?
- FacetWP group listings by custom field [closed]
- UnInstallation of a Plugin from a developers perspective – The correct and clean method
- Change wordpress current_time function to different timezone
- Creating custom HTML pages
- Frontent user submit and view content [closed]
- Center and hide overflow of WP toolbar custom links
- Is there a WordPress plugin that can post to Google+? [closed]
- WordPress checkbox and Illegal string offset
- dbDelta not adding additional columns in plugin database update
- Infinite scroll messing up nth:of-type
- Problem installing plugin: unexpected T_STRING, expecting T_FUNCTION
- How to Show Author image and url in WordPress plugin directory? [closed]
- jQuery code didn’t run on my plugin
- Color Picker UI in admin is not correct
- Create automatic latest version link
- Some error in mysql script ? Can’t working to create table
- list of custom post by custom field in frontend
- How to add a prefix to a WordPress post preview url?
- Change (replace) word in metabox
- Exclude Tag Links from and Text
- How to enable Admins to see Plugins
- Possible jquery / library conflict in plugin usage
- Display Plugin information on specific url
- How to add plugin to blog [closed]
- how to display the page content in popup window?
- Issue with customizer and widget page
- Posts in Admin only display 1 Post instead of all Post in admin area