Steve Taylor photo

Multiply WordPress posts in testing

Very often while building a WordPress site, I need to see how a layout works with a load of posts. Maybe 4, maybe 40. In any case, it’s tedious creating dummy content.

There’s a number of dummy content dumps out there to use, but often we’re working with custom post types and we need particular custom fields working right.

This bit of code will allow you to add a particular argument to the query (WP_Query, get_posts, etc.) to artificially multiply or repeat the posts returned.

Set pilau_multiply to an integer. The actual posts returned by that query will be repeated by that number of times.

NOTE: If you’re not using WP_Query, e.g. using get_posts(), you will need to set suppress_filters to false for this to work.