Custom Fields
Re-Envisioned
Support MB Views Custom post type query with twig, post link

  • Creator
    Topic
  • #19863
    Resolved jason@zrimarketing.com
    Participant

    Using the MB Views extension, I’m looping through a custom post type with the twig template engine. I’m not able to access the post url. Here is my code.

    
    <div id="services" class="center mw8 pa3 f3 lh-copy">
            <div class="flex flex-column flex-row">
                {% set args = { post_type: "service", posts_per_page: 6 } %}
                {% set posts = mb.get_posts( args ) %}
                {% for key, post in posts %}
                {% if key % 2 == 0 %}
                <section>
                {% endif %}
                    <div class="pv3 ph2">
                        <span class="ttu b f3 brand-primary bg-brand-secondary pa1 w-80 db">{{ post.post_title }}</span>
                        <p>{{ post.post_content|slice( 0, 130) }}...</p>
                        <a class="f4 b link dim br1 ph3 pv2 mb2 dib hover-brand-secondary brand-secondary bg-brand-primary" href="{{  post.post_link }}">Read More</a>
                    </div>
                {% if key % 2 != 0 %}
                </section>
                {% endif %}
                {% endfor %}
            </div>
        </div>
    
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.