Multiple post types in loop

Support MB Views Multiple post types in loop

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #40319
    Liam ColmanLiam Colman
    Participant

    Hi there,

    I'm trying to create a loop on one of my pages that includes multiple post types. The code I currently have is:

    
    {% set pt = { array( 'news', 'guide' ) } %}
    {% set args = { post_type: pt, posts_per_page: 12, facetwp: true } %}
    
    {% set posts = mb.get_posts( args ) %}
    
    {% for post in posts %}
    	<h1>
    		{{ post.title }}
    	</h1>
    {% endfor %}
    

    However, this throws an error. Could you please tell me what I'm doing wrong?

    Thanks!

    #40343
    PeterPeter
    Moderator

    Hello there,

    Please change the variable pt to this one

    {% set pt = [ 'news', 'guide' ] %}

    Let me know how it goes.

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