• Resolved Anonymous User 4309634

    (@anonymized-4309634)


    I’ve created a group which can be duplicated containing 2 fields which cannot be duplicated (WordPress 4.3.1 / Magic Fields 1.6.3.2)

    I’m trying to output the values but I’m just getting a blank – no errors but no data either.

    This is my code:

    <?php
    $nearest_locations = get_group('nearest_locations');
    if($nearest_locations) {
    foreach($nearest_locations as $nearest_location){
    echo $nearest_location['nearest_locations_location_name'][1]."<br />";
    echo $nearest_location['nearest_locations_location_distance'][1]."<br />";
    }}
    ?>

    I have read lots of threads on this and I don’t know what I’m doing wrong! Any help would be much appreciated ??

    https://www.ads-software.com/plugins/magic-fields/

Viewing 1 replies (of 1 total)
  • Thread Starter Anonymous User 4309634

    (@anonymized-4309634)

    I figured this out in the end:

    <?php
     // duplicate groups.
    
     // getGroupOrder us back an array of the order of groups
     // The parameter for this function is the name of a field belonging to the group
    
     $sites = getGroupOrder('nearest_locations_location_name');
     foreach($sites as $site){
     ?>
    
     <li class="<?php echo get('nearest_locations_indoor_session',$site); ?>">
     <?php
    
     // the second parameter of the function and get_image get is the index of the group to show
     $related_content = get('nearest_locations_location_link',$site);
     ?>
    
     <a href="<?php echo get_permalink($related_content); ?>">
    
     <?php
     echo get('nearest_locations_location_name',$site)."</a> (";
     echo get('nearest_locations_location_distance',$site).")";
     ?>
     </li>
     <?php  } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Duplicate Group with Magic Fields 1’ is closed to new replies.