Solved

Using Wordpress plugin "Magic Fields" outside of the loop

Posted on 2011-03-15
4
1,273 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
Comment Utility
So what have you done in the template?  The code for audio appears to be pretty straightforward.
0
 
LVL 1

Author Comment

by:Adam
Comment Utility
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
Comment Utility
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
Comment Utility
I played around with it a bit more and finally got the solution I was looking for.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now