Solved

Using Wordpress plugin "Magic Fields" outside of the loop

Posted on 2011-03-15
4
1,285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

751 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