Creating a "CPT Widget" using metabox View

Support MB Views Creating a "CPT Widget" using metabox ViewResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28462
    Viktor IwanViktor Iwan
    Participant

    Hello
    i'm new to metabox (from toolset) and i have question.
    i wanted to create a "widget" using the mb view that shows the "Latest News" from the custom post type "news"
    i tried creating view but the url/permalink and the image is showing up empty (only the post_title works)
    any suggestion where i did it wrong?
    Thank you

    {% set news = {post_type: 'news', posts_per_page: 5} %}
    {% set newss = mb.get_posts( news ) %}
    
    {% for news in newss %}
    
        <div class="list_news_page_item">
            <div class="news_cover_image">
                <a href="{{ news.url }}">
                <img src="{{ news.news_cover_image.medium.url }}" width="{{ post.news_cover_image.medium.width }}" height="{{ news.news_cover_image.medium.height }}" alt="{{ news.news_cover_image.medium.alt }}">
                </a>
            </div>            
    
            <div class="news_title">
                <a href="{{ news.post_url }}">
                {{ news.post_title }}
                </a>
            </div>
        </div>
    {% endfor %}
    #28472
    Long NguyenLong Nguyen
    Moderator

    Hi Viktor,

    Thank you for getting in touch.

    Post object does not have property field_id like post_title or post_content to access directly. You can get the field value via the helper function through the proxy mb.rwmb_meta()

    Refer to this topic https://support.metabox.io/topic/mb-view-by-shortcode/

    #28486
    Viktor IwanViktor Iwan
    Participant

    Thank you

    i will look into it..

    another question, how do you "var_dump" all the key and values? i want to know a method to look into all the key and values of the objects

    #28499
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please refer to this topic to print all custom fields related to a post ID https://support.metabox.io/topic/dump-all-available-custom-fields-from-mb-views/

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