Support Forum
Hi, Is possible to display the MB custom post fields from the WordPress post field select without an MB relationship connected?
{% for clone in post.menu_type %}
{% for clone in clone.add_dishes %}
{{ clone.title }}
<!--extra fields goes here BUT doenst show without MB relation -->
{{ post.dish_name }}
{{ post.dish_price }}
{% endfor %}
{% endfor %}
Hi Kirb,
Can you please share some screenshots of the View and clarify the questions? I understand that the field dish_name
and dish_price
belong to the post type Dish, and you want to show it on another post type page?
Yes. You are right. It is added in the single store post type. So basically I want to get the custom post fields from the dish
post type by adding them in the single store
post type.
Please see this screenshot of the single store page
https://markuphero.com/share/aicr2tfAqwmQLrF5VOg2
I want to get the custom fields from the dish and show them on the front-end. How can I do that? Because right now I'm only limited to these:
Hi,
So you need to create a relationship between CPT store
and dish
, then show the related post meta in View, please follow this documentation https://docs.metabox.io/extensions/mb-views/#relationship-fields
and refer to these topics
https://support.metabox.io/topic/relationship-cpt-title-not-displaying-using-mb-view-shortcode/
https://support.metabox.io/topic/query-in-relationship-post-per-page/
Hi I tried this but all the dishes are all added. I just want the dishes that are only added from store
page using the custom fields post
.
{% set args = { post_type: 'dish', nopaging: true} %}
{% set dishes = mb.get_posts( args ) %}
{% for dish in dishes %}
<a href="{{ mb.get_the_permalink( dish.ID ) }}">{{ dish.post_title }}</a>
{{ mb.rwmb_meta( 'dish_price', '', dish.ID ) }}
{% endfor %}
Please see this screenshot of the single store page
https://markuphero.com/share/aicr2tfAqwmQLrF5VOg2
i tried this as well
{% set args = { post_type: 'dish', nopaging: true} %}
{% set dishes = mb.get_posts( args ) %}
{% for dish in dishes %}
{% for clone in post.add_menu %}
{% for clone in clone.add_dishes %}
{{ clone.title }}
{% endfor %}
{% endfor %}
{% endfor %}
Hi Kirb,
You need to add the argument relationship
to the variable args
{% set args = { post_type: 'dish', nopaging: true, relationship: {id: 'store_to_dish', from: post.ID}} %}
Please read more on this article https://metabox.io/mb-views-how-to-display-relationships/