Custom Fields in Views

Support MB Views Custom Fields in Views

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #45437
    Mark DowdMark Dowd
    Participant

    I wrote some code that works but it cannot bring back any Custom Fields. How do I use the custom fields?

    {% set current_episode_program = post.episode_program.ID %}

    {% set episode_args = {
    post_type: 'episode',
    posts_per_page: -1,
    'post__not_in': [post.ID],
    meta_query: [
    {
    'key': 'episode_program',
    'value': current_episode_program,
    'compare': '='
    }
    ]
    } %}
    {% set episode_posts = mb.get_posts(episode_args) %}

    {% for episode_post in episode_posts %}
    <div>
    {{ episode_post.post_title }}
    {{ episode_post.episode_image }}
    </div>
    {% endfor %}

    #45440
    Mark DowdMark Dowd
    Participant

    To be clear

    {{ episode_post.post_title }} <--- comes back with no issue
    {{ episode_post.episode_image }} <--- Custom Field not returning

    Am I missing something?

    #45445
    PeterPeter
    Moderator

    Hello

    The image field could return an array and you cannot output the array directly. Please follow the example code in the documentation to output the image field
    https://docs.metabox.io/extensions/mb-views/#custom-query
    https://docs.metabox.io/functions/rwmb-meta/

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