Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So here's the problem, I want to have a few different meta boxes on my sites, but I'd like to be able to store each of them in separate files and included them into functions, so I can just copy specific ones to new installs and included them on a case by case basis.

From what I can gather though, it seems like I need to put them all into one array?

share|improve this question
    
Have you seen this at all? voodoopress.com/2011/04/… I've been playing around with it recently and really dig it. I can use it to set up any possible meta box I could want (text, wysiwyg, image, etc). You then just set up site specific meta box instances in your functions.php. –  Rev. Voodoo May 16 '11 at 13:14
    
the answer really depends on your setup and code. so provide some. –  Bainternet May 16 '11 at 13:56
add comment

1 Answer 1

up vote 2 down vote accepted

Save each meta box out to a file with the code as if they were in your functions.php file. Maybe place these in a folder called meta_boxes. Then to include into your theme just include() them into your functions file

<?php
// all the code that your functions file contains
include("meta_boxes/meta1.php");
include("meta_boxes/meta2.php");
include("meta_boxes/meta3.php");
include("meta_boxes/meta4.php");
// As so on....
?>
share|improve this answer
    
When I do that it only shows the last included item. –  Picard102 May 16 '11 at 15:59
    
By any chance you are repeating function names in both or more files? –  Brady May 16 '11 at 16:59
    
I didn't think I was, but I guess I must be if it's supposed to work. Here's the two functions I'm trying to create. leschinskidesign.com.php5-10.websitetestlink.com/test/… leschinskidesign.com.php5-10.websitetestlink.com/test/… –  Picard102 May 17 '11 at 14:32
1  
$prefix and $meta_box are getting overridden by the last include. Instead name them $prefix1, $prefix2 and so on for each meta box include –  Brady May 17 '11 at 14:46
    
ugh, how could I have not seen that. Thanks! –  Picard102 May 17 '11 at 15:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.