Solved

Using Wordpress plugin "Magic Fields" outside of the loop

Posted on 2011-03-15
4
1,279 Views
Last Modified: 2012-05-11
This might be a bit of a long-shot but I figured I'd post this question here.

I'm using a plugin called Magic Fields. It's a very powerful plugin that works similarly to custom fields but provides a lot more opportunities to customize the WP admin as a CMS.

Anyway, I have created a page where I will adding audio clips every now and then. I am planning on using the Magic Fields plugin so that all I would need to do is upload a few details, the audio file, and it would automatically populate on my page. I've created a template for my Audio page and have been trying out different things based off of the Magic Fields documentation to get it to work but haven't had any luck (so far, I've only been able to add one audio clip to my page).

Magic Fields has a wiki and a Google group - which I've looked through and still can't seem to figure out. But if they help, you can find them here.

http://groups.google.com/group/magic-fields
http://wiki.magicfields.org/doku.php

If someone has an idea of how I can do this, I would greatly appreciate it. Thanks!
0
Comment
Question by:Adam
  • 3
4 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35144390
So what have you done in the template?  The code for audio appears to be pretty straightforward.
0
 
LVL 1

Author Comment

by:Adam
ID: 35147049
Here is what I have so far:

$AudioClip = get_group("Audio Clip");

if($AudioClip){
   foreach($AudioClip as $Audio){
        echo get('audio_clip_title')."<br />"; // Clip Title
        echo get('audio_clip_description')."<br />"; // Clip Description
        echo get('audio_clip_file')."<br />";   // Clip File Name
   }
} 

Open in new window


Right now, its throwing out the details of the first audio clip twice. I'm not really much of a developer so I can't seem to figure out what I'm doing wrong.
0
 
LVL 1

Accepted Solution

by:
Adam earned 0 total points
ID: 35167785
I think I finally got this to work! (I'm using a WP audio plugin and added some HTML elements for styling - in case anyone is wondering)

$AudioClip = get_group("Audio Clip");
if($AudioClip){
   foreach($AudioClip as $Audio){
   echo '<div class="audio_clip">';
        echo '<h3>' . $Audio['audio_clip_title'][1] . '</h3>';
        echo '<p>' . $Audio['audio_clip_description'][1] . '</p>';
                
        $mp3 = $Audio['audio_clip_file'][1];
        
        
         if (function_exists('insert_audio_player')) {  
  			  insert_audio_player('[audio:' . $mp3 . ']' );  		
		} else {
			echo '<p><a href="' . $mp3 . '">Download</a></p>';
		}
		echo '</div>';   
	}
} 

Open in new window

0
 
LVL 1

Author Closing Comment

by:Adam
ID: 35196698
I played around with it a bit more and finally got the solution I was looking for.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
This article discusses how to create an extensible mechanism for linked drop downs.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The viewer will learn how to dynamically set the form action using jQuery.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question