Get group MF's from another custom post type while in that custom post type's loop?

13 views
Skip to first unread message

Rachel Vasquez

unread,
Jun 22, 2015, 10:24:52 PM6/22/15
to magic-...@googlegroups.com
Hi there!

I'm having this issue where I'm in a page template on a regular page. And since MF doesn't allow more than 1 level of duplicated groups, I had to create two custom post types. 

Ideally I would have wanted this:

One Post Type:
       Duplicated Group:
              Field 1
              Field 2
              Field 3
              Duplicated Group:
                     Field 1
                     Field 2
                     Field 3

But instead I had to do this:

One Post Type:
       Duplicated Group:
              Field 1
              Field 2
              Field 3

Second Post Type:
       Duplicated Group:
              Field 1
              Field 2
              Field 3

But the groups in the second post type are meant to be related to the first post type. So I'll need to pull one group in CPT2 per group in CPT1. But I'm getting stuck in the foreach loop of the first CPT and trying to find way to do this? Suggestions?


I'm using Magic Fields 2. I tried to use a for each loop and get_post_meta? But that doesn't work because I can't pull out the fields in their assigned group and can't pull specific fields. Here's what I have...



$chall_entries = get_group('challenge_entry', $post_id=4602); //The First Custom Post Type's Group

foreach($chall_entries as $war_task):
         
if( $war_task['challenge_entry_challenge_type'][1] == 'Warrior' ):
         
//The if statement was the only way I could ensure a specific group in CPT since they're duplicatable

                $war_task_id
= intval( $war_task['challenge_entry_assign_task'][1]) ;
                $war_task_posts
= get_post( $war_task_id ); //get ID inserted from CPT group field


                $meta_values
= get_post_meta( $war_task_id ); //use this id to get post meta


                echo
'<tr>'; //how do I loop through this post meta and still maintain groups in this second custom post type?
               
foreach ($meta_values as $meta_value) {
                  echo
'<td>' . $meta_value[1] . '</td>';
               
}


          endif
;
endforeach
;




Any thoughts would be much appreciated. I can post more code as well if needed. Thanks! :-)
Reply all
Reply to author
Forward
0 new messages