MB View shortcode including the CPT to pull the field contents from

Support MB Views MB View shortcode including the CPT to pull the field contents from

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35938
    Robert FeddesRobert Feddes
    Participant

    I want to use MB view shortcode to pull in specific CTA's in the content editor but can not get it to work.

    This is what I did:

    I added a CPT called CTAs

    I then made a Custom field group: Content CTAs with 3 fields: CTA text, CTA Button text, CTA target url

    This field group was connected to the Custom Post Type called CTAs

    I added a few Content CTAs to the CPT

    I made an MB view called CTA RPW type shortcode
    added a div and 3 p sections with each section calling a field

    The question now is how to use the schortcode so the different CTAs are shown via inputting the shortcode in the content editor.

    In other words how do I get the schortcode to include the custom post type to pull the fields from?

    The div and 3 p's are in the source of the frontend, but the fields are nog called from the CPT contents

    hope this makes enough sense for someone to help me

    #35945
    Long NguyenLong Nguyen
    Moderator

    Hi Robert,

    If you want to use the type Shortcode and display the list CTA with field values, you can use the custom query to query and display post type CTA. Read more on the documentation https://docs.metabox.io/extensions/mb-views/#custom-query

    #35956
    Robert FeddesRobert Feddes
    Participant

    Thanks Long Nguyen,

    If I were smart enough to understand the documentation that would be great, but I am not.

    So please help me out, how do I do that?

    The CPT slug is: content-ctas

    The view short code is: [mbv name="cta-rugpijn"]

    The post ID of one of the cta's is 2501, so please tell me, what must the shortcode then be?

    [mbv name="cta-rugpijn" ??="2501"]????

    Thanks!

    #35962
    Long NguyenLong Nguyen
    Moderator

    Hi Robert,

    If you want to use the View shortcode to render field values of a specific post, you can pass custom data (post ID) to the shortcode. For example:

    View shortcode: [mbv name="cta-rugpijn" my_post_id="2501"]

    View content:

    My Post Meta:
    
    {% set field_value_1 = mb.rwmb_meta( 'field_id_1', '', my_post_id ) %}
    {% set field_value_2 = mb.rwmb_meta( 'field_id_2', '', my_post_id ) %}
    
    {{ field_value_1 }} - {{ field_value_2 }}

    Read more on the documentation https://docs.metabox.io/extensions/mb-views/#custom-data

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