Associating, bulk adding complex fields
-
Hi again!
First off, I apologize I have so many questions, and I thank you for putting up with me! ??
I need help with sort of “associating” complex field information. For example, in this case:
<?php if ( $housereps = carbon_get_the_post_meta( 'house_reps', 'complex' ) ): ?> <?php foreach ( $housereps as $houserep ): ?> <div id="<?php echo sanitize_title_with_dashes ( $houserep['rep_last_name'] ); ?>" class="col s12 m6 offset-m3"><?php echo $houserep['rep_number']</div>
I have the fields
rep_last_name
andrep_number
, and I would like to display the information in that area as well as another area. In the other complex field, so far I have:<?php if ( $maptooltips = carbon_get_the_post_meta( 'map_tooltip_js', 'complex' ) ): ?> <?php $maptooltipinfo = ''; $i = 1; foreach ( $maptooltips as $maptooltip ) { ?> <?php $maptooltipinfo .= '\'<div class=bg-tooltip-header>District ' . $i++ . '</div><div class=bg-tooltip-desc><strong>Primary Voting Date</strong>: ' . $maptooltip['rep_primary_voting_date_tooltip'] . '<br><strong>General Election Voting Date</strong>: ' . $maptooltip['rep_gen_voting_date_tooltip'] . '</div><table class=bg-tooltip-table><thead><tr><th data-field=name>Name</th><th data-field=office>Office</th><th data-field=election>Election</th><th data-field=img>Image</th></tr></thead><tbody><tr><td>' . $maptooltip['rep_last_name_tooltip'] . '</td><td>House</td><td>' . $maptooltip['rep_type_of_election_tooltip'] . '</td><td><div class=image-cropper-map><div class=rounded-map style=background-image:url("' . $maptooltip['rep_img_tooltip'] . '")></div></div></td></tr></tbody></table>\'' . ','; } $maptooltipinfo = rtrim($maptooltipinfo,','); echo $maptooltipinfo ?> <?php endif ?>,];
but it’s far from what I’d want. In this case, I would like the
$maptooltip['rep_last_name_tooltip']
to be$houserep['rep_last_name']
except in that new area, depending on therep_number
. If therep_number
matches the complex field number in the new area, then I would like the information to be displayed.I have tried a few options, for example, building a nested foreach loop, but it didn’t work out ??
The last question for now was if there was a feature to bulk add complex fields.
Thanks for all the help, let me know if I need to clarify! ??
- The topic ‘Associating, bulk adding complex fields’ is closed to new replies.