field from settings page not displaying on frontend

Support MB Views field from settings page not displaying on frontend

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #29382
    jimimacjimimac
    Participant

    Hi,

    I've created a settings page and some custom fields. I then created a view where I have added the custom fields by clicking on the insert field button.

    I've put the shortcode into the page I want the info to show on but the values from the field arent displaying on the frontend. Im not sure why, if i use fields from other settings pages they display fine on the front end.

    #29383
    jimimacjimimac
    Participant

    here's my view code...

    <div style="width: 100%; display: flex; flex-direction: row;">
        <div class="lesson-prices">
            <p>
                30 mins
            </p>
            <p>
                60 mins
            </p>
        </div>
        <div class="lesson-prices">
            <p>
    
    {% set field = attribute( site.tuition, '30mins' ) %}
    {{ field }}
            </p>
            <p>
    {% set field = attribute( site.tuition, '60mins' ) %}
    {{ field }}
            </p>
        </div>
    </div>
    #29405
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can use the helper function rwmb_meta() via the proxy mb to get the field value from the settings page.

    {{ mb.rwmb_meta( 'field_id', {object_type: 'setting'}, 'option_name' ) }}

    Get more details here https://docs.metabox.io/extensions/mb-settings-page/#getting-field-value

    #29455
    jimimacjimimac
    Participant

    would i just replace the 'field_id' part with the actual field id when editing the view or would i need to set an option name too?

    #29459
    Long NguyenLong Nguyen
    Moderator

    Yes, you need to change field_id and option_name to your actual field ID and settings page option name.

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