I had the same issue, and found three ways to solve it. Types is really hard to convince to read data out of a different post than the current one in the loop…
That’s the first solution, just create a loop using query_posts() and get the data there via types_render_field()
as usual. Just remember to reset the query afterwards if you’re doing this before your actual loop; but i guess you know about that. http://codex.wordpress.org/Function_Reference/wp_reset_query
Inside the main loop, this is probably an almost impossible thing to do I guess.
The second solution is, iirc, to use setup_postdata($post) in you foreach-loop. This does some magic that finally point types_render_field()
into the post you want. Again, this messes with all the functions like the_ID()
or the_content()
and such, so you could store the old global $post
to a tmp variable and re-set it back via setup_postdata($tmp)
.
As the last resort, which is sometimes the least complicated one, you could just read the data manually by using get_post_meta(). To find the field name, it’s best to look directly into the wp_postmeta
table. I found a couple of guides for the naming convention of the fields in the database, but after some trial and error I always ended up starting Adminer to look at the DB.
So, choose wisely 🙂