Create a custom field that pulls the values from a field of a settings page

Support MB Builder Create a custom field that pulls the values from a field of a settings pageResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46243
    HenriHenri
    Participant

    Hi,

    I have created a custom Settings page which stores the links to my social media profiles. So the settings page has my LinkedIn url, Facebook url and Twitter url. This allows me to store these values in one place and use them all over the website.

    I also created a Custom Post type with Custom fields. I'm in the MB Builder to define the necessary custom fields and I would like to add a custom field that provides a dropdown with the social media profile urls stored in the Settings page, so that an author is able to select one of the social media profiles when he is creating or editing the Custom Post type.

    How can I define a Custom Field in the Meta Box builder that pulls those available values from the custom Settings Page?

    #46250
    HenriHenri
    Participant

    I forgot to mention that I would like to have it as a type of relationship, so that when the value changes of the field on the Settings Page, that then the new value is also used in the Custom Post type.

    How can I achieve this?

    #46256
    PeterPeter
    Moderator

    Hello Henri,

    If you want to use a field value on a settings page as the choice of a select field, you will need to use the code to register the field. Here is an example
    https://support.metabox.io/topic/dynamically-populate-the-options-of-a-select-custom-field-base-on-global-cf/#post-42765

    If you also want to update the field on the post after updating the field on the settings page, you can use the action hook rwmb_after_save_field
    Please follow the documentation https://docs.metabox.io/actions/rwmb-after-save-field/

    #46258
    HenriHenri
    Participant

    Hello Peter,

    Thanks for providing the links to the solution. I’ll try that.

    Have a good day 😊

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