Dump all available custom fields from MB Views

Support MB Views Dump all available custom fields from MB ViewsResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #28449
    Joseph ShrockJoseph Shrock
    Participant

    Hello, I am a Jr. developer and still trying to figure things out as I go along, it would be very very helpful for me to be able to dump all the available custom and related fields unto the custom-post to see what's all available to display, I have tried the following from MB Veiws in twig but just errors:

    <pre>
        {{ dump(post) }}
    </pre>

    I also have debug enabled in wp-config

    #28460
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please use the WordPress function get_post_custom() to get all meta fields base on the post ID.
    https://developer.wordpress.org/reference/functions/get_post_custom/

    #28465
    Joseph ShrockJoseph Shrock
    Participant

    Could you share the exact syntax I would need to use for that:

    <?php
    get_post_custom()
    ?>

    is not working.

    #28483
    Long NguyenLong Nguyen
    Moderator

    Hi Joseph,

    To run a PHP function in View, please use the proxy mb. Get more details on the documentation https://docs.metabox.io/extensions/mb-views/#running-php-functions

    There is a message under the View editor Supports any HTML/CSS/JS and shortcodes. Use Twig to write conditions, loops and more. To run a PHP function, use mb.function_name(param).

    #28502
    Joseph ShrockJoseph Shrock
    Participant

    Would you mind giving me the correct syntax for this, so I can just drop it on the page? - Thanks!

    #28517
    Long NguyenLong Nguyen
    Moderator

    Hi Joseph,

    You can try to use this code in View

    {% set post_meta = mb.get_post_custom( post.ID ) %}
    {{ mb.var_dump( post_meta ) }}

    Type: Singular, Location: Post, screenshot https://share.getcloudapp.com/YEuZlQAN

    #28533
    Joseph ShrockJoseph Shrock
    Participant

    That works, thank-you so much!

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