Always select from 1 custom field group's entry

Support General Always select from 1 custom field group's entryResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #48669
    dubiousmoot@gmail.com[email protected]
    Participant

    Hello, 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 time

    Widget

    #48670
    dubiousmoot@gmail.com[email protected]
    Participant

    So 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);
    #48671
    dubiousmoot@gmail.com[email protected]
    Participant

    Please note the AI solution breaks elementor's Theme Builder. Cannot edit the header with this code.

    #48679
    PeterPeter
    Moderator

    Hello,

    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.

    #48695
    dubiousmoot@gmail.com[email protected]
    Participant

    I 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.

    #48701
    PeterPeter
    Moderator

    Hello,

    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/

    #48705
    dubiousmoot@gmail.com[email protected]
    Participant

    Okay, I'll give it a try. Thanks for your time!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.