Magic Fields: Duplicate Fields within Duplicate Groups
-
Hi there,
I’m using the Magic Fields plugin (version 1.5.8.3, not the newer v2)
I’ve created a write panel where I can create duplicate groups.
In each group I have a field for the group title, which is not duplicated. I then have another fields for the group items, which can be duplicated.
I’m struggling to output all of this. It seems from reading the documentation that it can be done, but it all refers to specifying the group & field ID’s you want to show, not for just automatically outputting everything?
This code works, but it relies on me telling it which group ID I want to display the duplicates fields for:
<?php $mygroup = get_group('GroupName'); // use the Custom Group name foreach($mygroup as $group) { ?> <h1><?php echo $group['normal_field_name'][1]; // display a title for the group using a non-duplicated field ?></h1> <?php $fields = get_field_duplicate('duplicated_field_name',999); // get all the group items using duplicated fields foreach($fields as $field) { ?> <p><a href="<?php echo get_permalink($field); ?>" title="<?php echo get_the_title($field); ?>"><?php echo get_the_title($field); ?></a></p> <?php } ?> <?php } ?>
999 shows where I am told to specify the ID number of the group. How can I set this to retrieve the ID of the group displayed?
$group returns an array, not an ID number.
Just to add a little more complication, my duplicated field is a related type fields, hence the slightly complicated duplicate field code, which needs to retrieve the permalink & title for each related type field. This works fine though, i just can’t display the different groups!
Any ideas anyone?
I would guess this would be a fairly normal use of the duplicate fields and groups? I’m not sure why the documentation doesn’t go into this little bit more detail. I guess it’s pretty simple though, & I’m missing the blatantly obvious as usual!
[ Please do not bump, that’s not permitted here. ]
- The topic ‘Magic Fields: Duplicate Fields within Duplicate Groups’ is closed to new replies.