Hello.
I have a website of movies. In each movie i have different servers so the movie can be reproduced and seen by the users.
When i am editing / creating a post in wordpress, i have this:

It is in spanish, but it means "Servers in Latino (Spanish)", "Name of first server" and "Embed", and so with each. So i am able to put the name of the server and the embed code of various servers. I have 3 meta boxes like the one before, one for Latin Spanish, English Sub. and Spanish. This way, my server selector detects which server is on and which is off, which to display and which not to display. Example: If i name a server "Vk" then the Vk image and reproducer will be shown, if its field is empty nothing will be shown.
Image Example: 
But i want to go beyond it and make something like this.

So i would have a dropdown for Languages and for servers. Of course, these will be input type dropdown, which value is reflected on the theme with the php meta call in its respective language tab (Latin, Spanish, or English Sub):
PHP Code:
<?php
if ( get_post_meta($post->ID, 'dropdownlanguagefirst', true) ) { ?>
<span><a href="#tab15"><img src="http://www.nubecinema.com/wp-content/repro/netu.jpg" onmouseover="this.style.opacity=0.8" onmouseout="this.style.opacity=1" style="margin:0px 5px 10px;border: 1px solid white;border-radius: 6px;"></a></span>
<?php } ?>
So it will get the value of the dropdown and determine if it exists or not, if it exists it shows the image of a server (in this case Netu) if not, it will not show it.
But i don't know how to add the dropdown in functions.php of my wordpress. I think i understand that i have to add the function and then call it in the array like i do with "textarea", which brings a space for writing. This is what i have now:
PHP Code:
'Reproductores V.O.S.E. (VOSE means original language with subtitles)' => array (
array ( 'servidorprimerovose', '1er Servidor:', ),
array ( 'primerovose', 'Embed', 'textarea' ),
array ( 'servidorsegundovose', '2do Servidor:', ),
array ( 'segundovose', 'Embed:', 'textarea' ),
array ( 'servidortercerovose', '3er Servidor:', ),
array ( 'tercerovose', 'Embed', 'textarea' ),
array ( 'servidorcuartovose', '4to Servidor:', ),
array ( 'cuartovose', 'Embed:', 'textarea' ),
array ( 'servidorquintovose', '5to Servidor:', ),
array ( 'quintovose', 'Embed:', 'textarea' ),
array ( 'servidorsextovose', '6to Servidor:', ),
array ( 'sextovose', 'Embed:', 'textarea' ),
array ( 'servidorséptimovose', '7mo Servidor:', ),
array ( 'séptimovose', 'Embed:', 'textarea' ),
),
);
If i put instead of the text embed and input dropdown i don't know how to make it a meta field too, so it value can be called from the theme.
As i said 'textarea' brings a text area thanks to (i think):
PHP Code:
function text_field ( $args ) {
global $post;
// adjust data
$args[2] = get_post_meta($post->ID, $args[0], true);
$args[1] = __($args[1], 'sp' );
$label_format =
'<label for="%1$s">%2$s</label><br />'
. '<input style="width: 95%%;" type="text" name="%1$s" value="%3$s" /><br />';
return vsprintf( $label_format, $args );
}
function text_area ( $args ) {
global $post;
// adjust data
$args[2] = get_post_meta($post->ID, $args[0], true);
$args[1] = __($args[1], 'sp' );
$label_format =
'<label for="%1$s">%2$s</label><br />'
. '<textarea style="width: 95%%;" name="%1$s">%3$s</textarea><br /><br />';
return vsprintf( $label_format, $args );
}
/* When the post is saved, saves our custom data */
function sp_save_postdata($post_id, $post) {
global $sp_boxes;
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if ( ! wp_verify_nonce( $_POST['sp_nonce_name'], plugin_basename(__FILE__) ) ) {
return $post->ID;
}
¿So how do i add dropdown meta fields so they can be called?
Any help is aprecciated, thanks.
Bookmarks