Support Forum
Hi,
I am quite new in premium version, i am discovering all abilities of extensions... It is great !
I am missing someting with view and shortcode, HTML tags display well in page but no custom fields.
How to query my post type ?
Answer must be easy... Thank you for your help.
i tried this, it should work ?
<div class="markets">
{% set args = {post_type: "market", posts_per_page: 3} %}
{% set posts = mb.get_posts( args ) %}
{% for post in posts %}
{{ post.title }}
{% endfor %}
</div>
Ok, i can display the text field (text_test) 🙂
But not the image (logo_markey) 🙁
<div class="markets">
{% set args = {post_type: 'market', posts_per_page: -1} %}
{% set posts = mb.get_posts( args ) %}
{% for post in posts %}
{# Text #}
{{ post.text_test }}
{# Image #}
<img src="{{ post.logo_markey.full.url }}">
{% endfor %}
</div>
Ok, it works for me now 🙂
<div class="markets">
{% set args = {post_type: 'market', posts_per_page: -1} %}
{% set posts = mb.get_posts( args ) %}
{% for post in posts %}
{# Image #}
{% set image = mb.rwmb_meta( 'logo_market', '', post.ID ) %}
<img src="{{ image['full_url'] }} ">
{% endfor %}
</div>
I do not understand why i can not use mb view UI to insert this {{ post.logo_market.thumbnail.url }}...
Someone can explain ?
Thank you
Hi Régis,
Thank you for reaching out.
If you use the function get_posts()
, it will return post objects, we can call it a custom query. A post object does not support to access the field ID as a property of it.
You can get the post info via the post ID in a custom query by using the WordPress functions or our helper function rwmb_meta(). For example, featured image, use the function get_the_post_thumbnail().
<div class="markets">
{% set args = {post_type: 'market', posts_per_page: -1} %}
{% set posts = mb.get_posts( args ) %}
{% for post in posts %}
{# Image #}
{% set image = mb.rwmb_meta( 'logo_market', '', post.ID ) %}
<img src="{{ image['full_url'] }} ">
{{ mb.get_the_post_thumbnail( post.ID, 'thumbnail' ) }}
{% endfor %}
</div>
I will study taht 🙂
Thank you