Solved

Using Wordpress plugin "Magic Fields" outside of the loop

Posted on 2011-03-15
4
1,277 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Read about why website design really matters in today's demanding market.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

867 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

21 Experts available now in Live!

Get 1:1 Help Now