wp query – mix of 2 custom post types with post output in specific pattern

I’m trying to make a structure like this (see the most excellent diagram) with two different CPTs, video and commercials.

I want to mix two post types in a single wp-query so that they output in a specific pattern: 3 videos, one ad, 3 videos, one ad – up to a maximum of 16 posts. I don’t know if this is even possible, or it requires some kind of magic to work.

I have to consider that on the mobile view, there will be a single column of posts, and the same pattern should be repeated i.e. 3 videos then one ad, repeat. So using two WP queries in a 2 column layout is going to end up with displaying a bunch of videos, with the video on the left (per row) and the ad on the right (displaying one ad per row) (left column first) , and then a bunch of ads at the end (ie the right column). not optimal. They must be mixed somehow.

For what it’s worth, I’m using the JetEngine listing grid to display these posts, with fairly extensive wp-query settings. I haven’t found a way to specify a WP query object yet. In any case, I’m very glad to know if it is possible to do this with WP-Query, whether it will work with JetEngine or not.

Leave a Comment