Custom Fields
Re-Envisioned
Support MB Views Set the post ID in a view

  • Creator
    Topic
  • #28801
    Resolved gbreen@scopedesign.com
    Participant

    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 %}
Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #28830
    Long Nguyen
    Moderator

    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/fields/post/#data

    You can also share the code that creates the custom fields, I will help you to check the code.

    #28842

    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.

    #28844
    Long Nguyen
    Moderator

    Let me know if you have any questions.

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