Title: Magic Fields duplicates php error
Last modified: August 20, 2016

---

# Magic Fields duplicates php error

 *  Resolved [TootsieRoll](https://wordpress.org/support/users/tootsieroll/)
 * (@tootsieroll)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/magic-fields-duplicates-php-error-1/)
 * I’m trying to use duplicate a Magic Fields group and I just can’t get it to work.
   
   Here’ s the code that I am using in my template:
 *     ```
       <?php
       	$column_2 = getGroupOrder('column_2');
       	foreach($column_2 as $column_two){
       		echo get('column_2_news_headline', $column_two)."<br />";
       		echo get('column_2_news_paragraph', $column_two)."<br /><br />";
       	}
       ?>
       ```
   
 * And it’s outputting this pretty error:
    **Warning: Invalid argument supplied 
   for foreach()**
 * I read that I could get rid of the error but throwing an in statement in there
   like this:
 *     ```
       <?php
       	$column_2 = getGroupOrder('column_2');
       	if($column_2) {
       	foreach($column_2 as $column_two){
       		echo get('column_2_news_headline', $column_two)."<br />";
       		echo get('column_2_news_paragraph', $column_two)."<br /><br />";
       	}}
       	?>
       ```
   
 * The error isn’t there anymore, but it’s not out putting my content either…
    I’m
   not super knowledgable in php yet, but I’d like to get better at it, can anyone
   help me?

Viewing 1 replies (of 1 total)

 *  Thread Starter [TootsieRoll](https://wordpress.org/support/users/tootsieroll/)
 * (@tootsieroll)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/magic-fields-duplicates-php-error-1/#post-2388928)
 * I’ve sorted it out:
 *     ```
       <?php
       	$column_2 = get_group('Column 2');
       	if($column_2) {
       	foreach($column_2 as $column_two){
       		echo $column_two['column_2_headline'][1]."<br />";
       		echo $column_two['column_2_text'][1]."<br />";
       	}}
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Magic Fields duplicates php error’ is closed to new replies.

## Tags

 * [Duplicate groups](https://wordpress.org/support/topic-tag/duplicate-groups/)
 * [foreach](https://wordpress.org/support/topic-tag/foreach/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [magic field](https://wordpress.org/support/topic-tag/magic-field/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [TootsieRoll](https://wordpress.org/support/users/tootsieroll/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/magic-fields-duplicates-php-error-1/#post-2388928)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
