Generating PHP and Displaying Settings on Frontend

Support General Generating PHP and Displaying Settings on FrontendResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33122
    Jack_BJack_B
    Participant

    Hi,

    I just purchased the plugin and was wondering if it's possible to generate the PHP required for displaying fields on the front end.

    I'm coming from ACF where you could use an extension to write this for you (https://hookturn.io/downloads/acf-theme-code-pro/?utm_source=awesomeacflink). Is there something equivalent for Metabox?

    I can see you can generate it with Views, which I thought was the same - although it uses Twig (I think), so i can't use that code directly in templates.

    If it's not possible, could I please have some assistance with displaying a settings field in my templates. I have created a settings page. This is what's generated in Views:

    {% set group = attribute( site, 'global-settings' ) %}
    {{ group.opening_hours }}

    How can I translate that to the plain php equivalent?

    $value = rwmb_meta( $field_id, ['object_type' => 'setting'], $option_name );
    echo $value;

    I'm not sure how to declare the option name.

    Thanks in advance

    #33145
    Long NguyenLong Nguyen
    Moderator

    Hi,

    it's possible to generate the PHP required for displaying fields on the front end.

    Meta Box does not support a feature to generate code to output the field value like that.

    If you want to get the field value of the settings page, please clarify the field ID and option name. For example:

    $value = rwmb_meta( 'text_id', ['object_type' => 'setting'], 'my_option' );
    echo $value;

    Get more details on the documentation
    https://docs.metabox.io/displaying-fields/#using-code
    https://docs.metabox.io/extensions/mb-settings-page/

    #33151
    Jack_BJack_B
    Participant

    Thank you, I was able to get the snippet you posted to work

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