Results 1 to 3 of 3

Thread: Checkboxes in functions.php on wordpress

  1. #1
    Join Date
    Jul 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Checkboxes in functions.php on wordpress

    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:

    Click image for larger version. 

Name:	default.jpg 
Views:	109 
Size:	55.5 KB 
ID:	5501

    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: Click image for larger version. 

Name:	langs.JPG 
Views:	98 
Size:	22.6 KB 
ID:	5502

    But i want to go beyond it and make something like this.

    Click image for larger version. 

Name:	new.jpg 
Views:	99 
Size:	55.2 KB 
ID:	5503

    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.
    Last edited by Rodrigo8; 07-15-2014 at 01:18 AM. Reason: Resolved

  2. #2
    Join Date
    Jul 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Close this thread please, new doubt in post aprobbal.

  3. #3
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Rodrigo8 View Post
    Close this thread please, new doubt in post aprobbal.
    You can just set it as "resolved."
    Jeremy | jfein.net

Similar Threads

  1. Calling Functions from Functions.
    By clowes in forum JavaScript
    Replies: 32
    Last Post: 12-21-2009, 04:43 AM
  2. Resolved disable other checkboxes if 3 checkboxes are checked
    By al3bed in forum JavaScript
    Replies: 1
    Last Post: 08-28-2009, 04:41 PM
  3. checkboxes
    By cassy in forum JavaScript
    Replies: 2
    Last Post: 06-12-2009, 09:59 AM
  4. WordPress time functions
    By chechu in forum Looking for such a script or service
    Replies: 0
    Last Post: 06-01-2009, 09:45 AM
  5. Disable checkboxes based in other checkboxes.
    By gastongr in forum JavaScript
    Replies: 11
    Last Post: 04-24-2006, 11:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •