• I would like to insert a date using custom fields (for example: a dvd release date). On a certain page I would like to show a selection of posts in a certain date range, based on those custom fields.

    What would be the best way to setup my custom fields and make the corresponding selection/query?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hijacking the thread, since my question is the same.

    I would like to use the jQuery datepicker:
    http://ui.jquery.com/functional_demos/#ui.datepicker

    Since I heard that wp already uses jQuery. I read I have to use in my plugin the command:

    wp_enqueue_script(‘jquery’);

    This ensures the jQuery library to be correctly included in the head section of the page, and it works.

    Now following the guide on the above link, i should use:

    $(“#basics”).datepicker();

    Where #basics is the id of my date input text field to bind it to the datepicker functionalty, but where/when should I use that code? I tried just below the input text but, obviously doesn’t work.

    (I even don’t know if I have to inlude other scripts to make the datepicker work or the ‘jquery’ alone is enough)

    Thanks in advance.

    I’m doing the same thing. Here’s what you need to get the jQuery datepicker working:

    //datepicker script
    wp_enqueue_script('jquery-ui-datepicker', 'path/to/ui.datepicker.js', array('jquery','jquery-ui-core'), '1.7.1');
    
    /*my js init file...
    jQuery(document).ready(function(){
    	jQuery("#jquery-calendar").datepicker({
    		showOn: 'both',
    		buttonImage: 'img/calendar.gif',
    		buttonText: 'Choose',
    		buttonImageOnly: true,
    		changeMonth: true,
    		changeYear: true
    	});
    });
    */
    wp_enqueue_script('my-datepicker-js','path/to/js.js', array('jquery','jquery-ui-core','jquery-ui-datepicker'));
    
    //path to jQuery UI theme stylesheet
    wp_enqueue_style('jquery-ui','http://jqueryui.com/latest/themes/cupertino/ui.all.css');
    
    wp_print_styles();

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to use custom fields as a date picker.. and query the dates?’ is closed to new replies.