Always select from 1 custom field group's entry
- This topic has 6 replies, 2 voices, and was last updated 1 week, 5 days ago by
[email protected].
-
AuthorPosts
-
August 7, 2025 at 9:05 PM #48669
[email protected]
ParticipantHello, maybe I'm overthinking here. I am using elementor pro's animated message widget for my header's top bar section. There will only be 1 entry to select from, but how do I get the query for that field? For now the middle section has static text (it's live). But the 2 outer sections are selected correctly dynamically, yet I still need to somehow select the correct field.
Hoping this is explained well enough, thank you for your timeAugust 7, 2025 at 9:34 PM #48670[email protected]
ParticipantSo AI seems to have fixed the issue (for now). This is a temporary solution unless someone more knowledgeable has a more refined solution.
// Filter the dynamic tag values specifically add_filter('elementor/dynamic_tags/custom_field/value', function($value, $settings, $tag) { // Only modify if we're in a header template and the field matches our topbar fields if (strpos($settings['key'], 'topbar-') === 0) { $header_post = get_posts(array( 'name' => '18318', 'post_type' => 'top-bar-message', 'numberposts' => 1, 'post_status' => 'publish' )); if (!empty($header_post)) { $value = get_post_meta($header_post[0]->ID, $settings['key'], true); } } return $value; }, 10, 3);
August 7, 2025 at 10:01 PM #48671[email protected]
ParticipantPlease note the AI solution breaks elementor's Theme Builder. Cannot edit the header with this code.
August 8, 2025 at 11:01 PM #48679Peter
ModeratorHello,
Thanks for reaching out.
Do you mean the field Before text, After text? I see you are selecting Meta Box fields for them and what is the issue there? Please share a screen record so I can understand it better.
August 13, 2025 at 3:33 AM #48695[email protected]
ParticipantI have the Post type and Custom Fields set up.
The information from these fields are to be used in the Navigation Top Bar area (small bar above the header).
I will only use the 1 entry for the fields. No need for a loop, we will only change the info as needed from the 1 post.
I have the Animated headline in the top bar which is included in the elementor header theme.Previously I didn't want to make a loop, simply select from the post type. I decided to make a loop then told my client to not delete the current post or add new posts. I think this will work.
Thank you so much for your time.
August 13, 2025 at 9:01 PM #48701Peter
ModeratorHello,
I will only use the 1 entry for the fields. No need for a loop, we will only change the info as needed from the 1 post.
If you want to get one field value to display on all pages, you can consider using the Settings page, like the theme options. No need to use a post or a page that can be deleted after.
Following the documentation https://docs.metabox.io/extensions/mb-settings-page/August 13, 2025 at 10:43 PM #48705[email protected]
ParticipantOkay, I'll give it a try. Thanks for your time!
-
AuthorPosts
- You must be logged in to reply to this topic.