PHP code example of voceconnect / voce-post-meta-date

1. Go to this page and download the library: Download voceconnect/voce-post-meta-date library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

voceconnect / voce-post-meta-date example snippets


if( ! class_exists( 'Voce_Post_Meta_Date' ) ) {
	


add_action('init', function(){
	add_metadata_group( 'demo_meta', 'Page Options', array(
		'capability' => 'edit_posts'
	));
	add_metadata_field( 'demo_meta', 'demo_key', 'Start Date', 'date' );
	add_post_type_support( 'page', 'demo_meta' );
	
});


add_action('init', function(){
	add_metadata_group( 'demo_meta', 'Page Options', array(
		'capability' => 'edit_posts'
	));
	add_metadata_field( 'demo_meta', 'demo_from', 'From', 'date', array(
		'max_date_field' => 'demo_meta_demo_to',
		'max_date' => '2013/08/25 2:00',
		'default_text' => 'Enter Value, Sir!',
	));
	add_metadata_field( 'demo_meta', 'demo_to', 'To', 'date', array(
		'min_date_field' => 'demo_meta_demo_from',
		'default_date' => '2013/08/28 5:00',
	));

	// Note: more than one field can use the same max_date_field/min_date_field
	add_metadata_field( 'demo_meta', 'demo_alt_to', 'Alternative To', 'date', array(
		'min_date_field' => 'demo_meta_demo_from',
	));

	add_post_type_support( 'page', 'demo_meta' );
});