Support Forum
I am trying to create a view from a post with sections and pages that are clonable. Below you can see the view I am starting to make. You can see here
{% set post = mb.get_post( the_post_id ) %}
the post id is being set via a function in this case its 16. Some fields show properly {{ clone.section_name }}
and {{ clone.page_name }}
work fine. {{ clone.page_name }}
does not work.
If I do not use the short code and just show the page removing
{% set the_post_id = mb.get_pid() %}
{% set post = mb.get_post( the_post_id ) %}
it all works.
Ultimately how can I set the post I want the view to show if I use the shortcode?
Menu
{#
Get the post id
mb.get_pid() is pulling from a function set in snippits
#}
{% set the_post_id = mb.get_pid() %}
{% set post = mb.get_post( the_post_id ) %}
{# Build the menu #}
{% for clone in post.section %}
{{ clone.section_name }}
{% for clone in clone.page %}
{{ clone.page_name }}
{{ clone.post.title }}
{% endfor %}
{% endfor %}
Hi,
Thank you for getting in touch.
If you use the field post
to select a page and save it as the custom field of a post, please use the WordPress function to get the page title. Get more details here https://docs.metabox.io/extensions/mb-views/#running-php-functions
You can also share the code that creates the custom fields, I will help you to check the code.
I'm all good. I ended up just using php to make the view. There were just to many places that were taking to long to do in the view. It may be possible I just ran out of time to play.
Let me know if you have any questions.
The same point here. Did you find out how to pass a post id into the shortcode for viewing the complete post for this id?
Hi @cybercore,
You can follow this documentation to know how to pass data (post ID) to the shortcode via custom attributes https://docs.metabox.io/extensions/mb-views/#custom-data