Getting Settings Page Fields in Views

Support MB Settings Page Getting Settings Page Fields in ViewsResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #43112
    AMXAMX
    Participant

    Hi,

    I am trying to output settings fields in Views using the GUI and there is no output on the front end.

    The "Insert Field" button adds such markup for a single image field:

    {% set group = attribute( site, 'site-options' ) %}
    <img src="{{ group.default_page_hero_1.full.url }}" width="{{ group.default_page_hero_1.full.width }}" height="{{ group.default_page_hero_1.full.height }}" alt="{{ group.default_page_hero_1.full.alt }}" />
    

    But it doesn't work. It doesn't work even for simple text fields.

    For text fields, I adapted a php function that a user posted:

    {{ mb.get_option('site-options')['my-field'] }}

    But why the GUI method doesn't work and how can I easily output the image tag from a settings page field?

    Greetings,
    Tom

    #43113
    AMXAMX
    Participant

    Here is the formatting corrected:

    {% set group = attribute( site, 'site-options' ) %}
    <img src="{{ group.default_page_hero_1.full.url }}" width="{{ group.default_page_hero_1.full.width }}" height="{{ group.default_page_hero_1.full.height }}" alt="{{ group.default_page_hero_1.full.alt }}">
    #43128
    PeterPeter
    Moderator

    Hello,

    I see the attribute() function returns the value correctly on my demo site. You can use the WordPress function get_option() as you do or the Meta Box helper function rwbm_meta() to get a settings page value. Refer to the documentation https://docs.metabox.io/extensions/mb-settings-page/#getting-field-value

    #43566
    AMXAMX
    Participant

    Thanks.

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