How to load / use Custom Fields created by ACF in MB Views

Support MB Views How to load / use Custom Fields created by ACF in MB ViewsResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #37102
    keith.mason@akcreation.co.uk[email protected]
    Participant

    Hi there, I am trying to code a 'View' using MB Views, which will load in custom fields that are created by the ACF extension (I understand that I can use Metabox for this, but due to technicalities on this project I need to use ACF for my custom fields).
    However, the fields I have setup using ACF, do not show when I click 'Insert Field' in the 'Edit View' screen.
    My custom field ID is 'office_location', so I tried loading it in by typing '{{ post.office_address }}' however if this does not work (nothing gets returned, but I know this has been filled in).

    So, is this possible? And if so, how is it done please? Please can you provide me with the code I would need to input / specific instructions (and not just a link to your documentation as I have looked and searched through them and found nothing).

    Thanks in advance for your help,

    Keith

    #37103
    keith.mason@akcreation.co.uk[email protected]
    Participant

    sorry I mistyped - I meant to say my custom field ID is 'office_address'

    #37108
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Both Meta Box and ACF custom fields save values in the table wp_postmeta for regular fields, so in this case, you can use the WordPress function get_post_meta() to get/display the field value in View

    {{ mb.get_post_meta( post.ID, 'office_address' ) }}

    Read more on the documentation
    https://developer.wordpress.org/reference/functions/get_post_meta/
    https://docs.metabox.io/extensions/mb-views/#running-php-functions

    #37130
    keith.mason@akcreation.co.uk[email protected]
    Participant

    That's great thank you Long - much appreciated 🙂

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