WordPress.org

Forums

Magic Fields
Duplicate group returns image as Array (2 posts)

  1. Yusri Mathews
    Member
    Posted 2 years ago #

    Below is my code, everything else works fine except the image. It returns "Array".

    $profiles = get_group('Teacher');
    		    foreach($profiles as $profile){
    		    	echo "<div class=\"side-er teacher fl-left\">";
    				echo "".$profile['teacher_image'][1]."";
    		    	echo "</div>";
    		    	echo "<div class=\"full-content fl-right\">";
    		    	echo "<h2>".$profile['teacher_full_name'][1]."</h2>";
    		    	echo "<p>".$profile['teacher_content'][1]."</p>";
    		    	echo "<p>Contact Details:<br />";
    		    	echo "Cell: ".$profile['teacher_cell'][1]."<br />";
    		    	echo "Email: <a href=\"".$profile['teacher_email'][1]."\">".$profile['teacher_email'][1]."</a></p>";
    		    	echo "</div>";
    		    	echo "<div class=\"clear-fix\"></div>";
    		    }

    If I call get('teacher_image'); The images shows but only the first groups image on all groups.

    Any suggestions?

    http://wordpress.org/extend/plugins/magic-fields/

  2. Yusri Mathews
    Member
    Posted 2 years ago #

    Okay so I found the answer. After $profiles = get_group('Teacher'); insert pr($profiles);. It will then return a whole bunch of code and feed you back with "pre" text. It then shows you the array of types for your image. You then select which ever one and insert it into your code. Remeber to remove the pr($profiles)

    Below is a snippet of the complete working code:

    $profiles = get_group('Teacher');
    		    foreach($profiles as $profile){
    		    	echo "<div class=\"side-er teacher fl-left\">";
    		    	echo "".$profile['teacher_image'][1]['src']."";
    		    	echo "</div>";
    		    	echo "<div class=\"full-content fl-right\">";
    		    	echo "<h2>".$profile['teacher_full_name'][1]."</h2>";
    		    	echo "<p>".$profile['teacher_content'][1]."</p>";
    		    	echo "<p>Contact Details:<br />";
    		    	echo "Cell: ".$profile['teacher_cell'][1]."<br />";
    		    	echo "Email: <a href=\"".$profile['teacher_email'][1]."\">".$profile['teacher_email'][1]."</a></p>";
    		    	echo "</div>";
    		    	echo "<div class=\"clear-fix\"></div>";
    		    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Magic Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic