Inserting custom data to the_post() during loop

Yep, it’s not very common, but perfectly viable and nifty technique.

After the posts are retrieved in WP_Query they are passed through the_posts filter like this (where $this is WP_Query instance):

$this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) );

You just loop through array and assign the extra data you need to objects. Don’t forget to check the query for being right query you want to target.

error code: 523