I’m a bit stumped with this one. I’m using wordpress and I’d like to query multiple custom post types using some kind of ratio and display them on a page.
Let’s say I have the following post types:
tweet, project, video & post
At the moment my current query result is flooded with tweets and all the other post types are being pushed down the page.
Is there a way to formulate a query so that (say) 25% of the result is taken up by tweets and the remaining 75% taken up by the other post types? Essentially I’d like to reduce the number of tweets that are appearing in my query result.
I hope that makes sense.
Many thanks
I would probably handle this manually with 2 separate custom queries (using WP_Query). I’m going to assume you want paging enabled (since it’s your only blogroll and eventually this will get very large). In general, the strategy is going to be:
1) Build two different queries (1 for your projects, videos, and posts… And 1 for your tweets).
2) Setup the ratio you’d like to mix using the
posts_per_page
attribute of your query arguments.3) Loop each query, but don’t output their titles or content just yet, but rather, store each in its own array.
4) Create a new array to contain your “shuffled” blogroll.
5) Loop through this new array to output the content.
I didn’t test this code, so treat it sort of like pseudocode. But the general idea is hopefully clear.
Have fun!