This is a stripped down version of what I have been doing. I hope I haven’t busted the code by stripping it down badly!
<?php // start your duplicated fields loop
$related_content_fields = getFieldDuplicates('your_related_content_field_name', 1);
for($i = 1; $i < $related_content_fields+1; $i++):
// gets the ID for each related content post/page
$related_content_id = get('your_related_content_field_name',1,$i,true);
?>
<?php // these work by using the ID we have collected and stored above ?>
<?php echo get_the_post_thumbnail($related_content_id, 'your_featured_image'); ?>
<a href="<?php echo get_permalink($related_content_id); ?>">
<h2><?php echo get_the_title($related_content_id); ?></h2>
</a>
<?php // this works by just accessing the magic field in the duplicate ?>
<p><?php echo get('magic_fields_name',1,$i); ?></p>
<?php endfor; ?>
I’m not sure your code above was calling in the field duplicates quite right, as you need to start a count for all the duplicates & use that later. Was that definitely working?
I did find a bit more code that i have, but I won’t include it here as it might get confusing, but it is for when the post or page you are linking to in your related type fields ALSO has a related type filed in it & you want to access that info. For example, I used it in the following situation:
I had created a post Category that I was using to create calendar events. I used the duplicated related type field so that I could create multiple lists of these events in a custom loop. In my sidebar for example on any specific page, i could add 2 or three events relevant to that page.
The code above was used to display both generic WP fields & to create links for that event content.
What I had done for the event posts, however, was use another related type field on each event write panel, which allowed you to link to a ‘venue’ post. Another post category for ‘venues’ was created to allow me to build up an archive of all the different venues.
If I wanted to be able to access the ‘venues’ magic fields, from within the ‘events’ duplicated related type loop, there was additional code required.
Like I say, I’ll leave it out unless it sounds useful to you!?
I’m pretty sure that what I have done is exceed the recommended use for post categories, but it all works. It should probably be done now using custom taxonomies, which are handled much better in the new version of Magic Fields 2, but I haven’t got my head around that yet!