Support Forum
How can I display existing content in custom fields? In my booking site project I would like to display destination info depending on the chosen hotel. I want to manage destination info in one place (post), so that changes reflect automatically everywhere.
Basically this - in the CPT, under destination info, I would like to have checkboxes with destination names. If I click Toronto, on the frontend there should be displayed the Toronto destination info (Toronto post). And when I update Toronto post, the change is updated in all Toronto destination infos.
Hi,
To update one field value and apply for all posts, I think you should use the Taxonomy. Toronto or New York ... should be the term and information of this place is the term meta. So when you change the information of a place, it will change on all posts assigned to this term.
Thank you for the reply. I did as instructed - or, how I understood it 🙂 I added all the destination infos as custom fields, and it works when I add them to single template in elementor.
But I have two problems now:
1) I cannot display the destination gallery - I added the gallery as Image Advanced post type. What's the correct way to setup the custom field and display the galleries?
2) How would I display custom fields for more than one post? I created a vacation package, and added the hotel fields. it displayed on the frontend when there was just one hotel added. But when I added the second hotel, the fields became blank.
So, if I want to display two available hotels in one package, how do I do that? What's the general logic of letting hthe WordPress know it needs to display fields for all CPT connected with those fields?
Hi,
To show images from the field image_advanced
, please follow this documentation https://docs.metabox.io/fields/image-advanced/#template-usage
Custom field saved value against a unique post, if you want to show a field value for many posts, you can create a new term/taxonomy and assign it to many posts as you want.
That is, I added Imagedvanced images to both types of posts - Vacations and Hotels. With the code I can display Vacations images on Vacations single post template.
But how can I display images from Hotels posts on Vacations template? (They are linked in MB Relationships.)
Hi,
To get the field value from Hotels posts on Vacations posts, you need to pass the third arguments to the helper function
rwmb_meta( 'image_advanced', '', $p->ID );
Follow on the documentation
https://docs.metabox.io/extensions/mb-relationships/#getting-connected-items
https://docs.metabox.io/rwmb-meta/#arguments
I'm not a developer, but I did manage to follow the advice. I added that last code before the helper function using the insert php plugin, and the images are outputted like I want them, finally.
But I am getting an error above the images:
Warning: Undefined variable $p in C:\xampp\htdocs\elementor\wp-content\plugins\insert-php-code-snippet\shortcode-handler.php(65) : eval()'d code on line 2
Warning: Attempt to read property "ID" on null in C:\xampp\htdocs\elementor\wp-content\plugins\insert-php-code-snippet\shortcode-handler.php(65) : eval()'d code on line 2
This is the code:
<?php
rwmb_meta( 'image_advanced', '', $p->ID );
rwmb_the_value( 'holidayimg', array( 'size' => 'Thumbnail' ) );
How can I fix this?
Hi,
How did you get the connected posts via Relationships? Please get details on this documentation https://docs.metabox.io/extensions/mb-relationships/#getting-connected-items
After showing the content of the connected posts, you can use the helper function to show the image of Hotels posts on Vacations posts.
Is there anything in Metabox like Relationship field type in ACF? This is exactly what I need, this guy is displaying Dealerships info using that (jump to 3:28).
Hi,
Thanks for your feedback.
Meta Box has the extension MB Relationships or field type post works similar to the relationship field type of ACF in the backend. But we have to use the code to show the info of the relation posts.
I will inform the development team to make it compatible with Elementor and other page builders for easier drag and drop.
Thanks, that would be nice. Adding a simpler way of displaying image gallery would also be super helpful.
For what it's worth, if someone's reading this looking for an answer, I managed to solve all the problems in this thread using Elementor custom skin, Advanced Post Queries (free plugin) and ACF.
Everything works with Metabox too, except displaying fields from posts in relation (though, as suggested, it could be done).