Return to Snippet

Revision: 28586
at October 9, 2010 04:51 by ebiansyah1402


Updated Code
<?php
//register Gallery post type
add_action('init', 'gallery_register');
 
function gallery_register() {
 
	$labels = array(
		'name' => __('Gallery', 'post type general name'),
		'singular_name' => __('Gallery Item', 'post type singular name'),
		'add_new' => __('Add New', 'gallery item'),
		'add_new_item' => __('Add New Gallery Item'),
		'edit_item' => __('Edit Gallery Item'),
		'new_item' => __('New Gallery Item'),
		'view_item' => __('View Portfolio Item'),
		'search_items' => __('Search Gallery'),
		'not_found' =>  __('Nothing found'),
		'not_found_in_trash' => __('Nothing found in Trash'),
		'parent_item_colon' => ''
	);
 
	$args = array(
		'labels' => $labels,
		'public' => true,
		'publicly_queryable' => true,
		'show_ui' => true,
		'query_var' => true,
		'rewrite' => true,
		'capability_type' => 'post',
		'hierarchical' => false,
		'menu_position' => null,
		'supports' => array('title','editor','thumbnail')
	  ); 
 
	register_post_type( 'gallery' , $args );
}
// Register "Site type" taxonomy (As Category)
register_taxonomy("Site Type", array("gallery"), 
	array(
	"hierarchical" => true, 
	"label" => "Site Type", 
	"singular_label" => "Site Type", 
	"rewrite" => true)
	);
	
//Resgister "Color" Taxonomy (As Tags)
register_taxonomy("Color", array("gallery"),
	array(
	"hierarchical" => false,
	"label" => "Color",
	"singular_label" => "Color",
	"rewrite" => true)
	);
	
//gallery post meta field for website URL or source URL	
add_action("admin_init", "admin_init");

function admin_init(){
  add_meta_box("source_url", "Source URL", "source_url", "gallery", "normal", "low");
}
 
function source_url(){
  global $post;
  $custom = get_post_custom($post->ID);
  $source_url = $custom["source_url"][0];
  ?>
  <label>source URL:</label>
  <input name="source_url" value="<?php echo $source_url; ?>" />
  <?php
}
?>

Revision: 28585
at October 7, 2010 20:42 by ebiansyah1402


Updated Code
//register Gallery post type
add_action('init', 'gallery_register');
 
function gallery_register() {
 
	$labels = array(
		'name' => __('Gallery', 'post type general name'),
		'singular_name' => __('Gallery Item', 'post type singular name'),
		'add_new' => __('Add New', 'gallery item'),
		'add_new_item' => __('Add New Gallery Item'),
		'edit_item' => __('Edit Gallery Item'),
		'new_item' => __('New Gallery Item'),
		'view_item' => __('View Portfolio Item'),
		'search_items' => __('Search Gallery'),
		'not_found' =>  __('Nothing found'),
		'not_found_in_trash' => __('Nothing found in Trash'),
		'parent_item_colon' => ''
	);
 
	$args = array(
		'labels' => $labels,
		'public' => true,
		'publicly_queryable' => true,
		'show_ui' => true,
		'query_var' => true,
		'rewrite' => true,
		'capability_type' => 'post',
		'hierarchical' => false,
		'menu_position' => null,
		'supports' => array('title','editor','thumbnail')
	  ); 
 
	register_post_type( 'gallery' , $args );
}
// Register "Site type" taxonomy (As Category)
register_taxonomy("Site Type", array("gallery"), 
	array(
	"hierarchical" => true, 
	"label" => "Site Type", 
	"singular_label" => "Site Type", 
	"rewrite" => true)
	);
	
//Resgister "Color" Taxonomy (As Tags)
register_taxonomy("Color", array("gallery"),
	array(
	"hierarchical" => false,
	"label" => "Color",
	"singular_label" => "Color",
	"rewrite" => true)
	);
	
//gallery post meta field for website URL or source URL	
add_action("admin_init", "admin_init");

function admin_init(){
  add_meta_box("source_url", "Source URL", "source_url", "gallery", "normal", "low");
}
 
function source_url(){
  global $post;
  $custom = get_post_custom($post->ID);
  $source_url = $custom["source_url"][0];
  ?>
  <label>source URL:</label>
  <input name="source_url" value="<?php echo $source_url; ?>" />
  <?php
}

Revision: 28584
at July 10, 2010 03:39 by ebiansyah1402


Initial Code
//register Gallery post type
add_action('init', 'gallery_register');
 
function gallery_register() {
 
	$labels = array(
		'name' => __('Gallery', 'post type general name'),
		'singular_name' => __('Gallery Item', 'post type singular name'),
		'add_new' => __('Add New', 'gallery item'),
		'add_new_item' => __('Add New Gallery Item'),
		'edit_item' => __('Edit Gallery Item'),
		'new_item' => __('New Gallery Item'),
		'view_item' => __('View Portfolio Item'),
		'search_items' => __('Search Gallery'),
		'not_found' =>  __('Nothing found'),
		'not_found_in_trash' => __('Nothing found in Trash'),
		'parent_item_colon' => ''
	);
 
	$args = array(
		'labels' => $labels,
		'public' => true,
		'publicly_queryable' => true,
		'show_ui' => true,
		'query_var' => true,
		'rewrite' => true,
		'capability_type' => 'post',
		'hierarchical' => false,
		'menu_position' => null,
		'supports' => array('title','editor','thumbnail',)
	  ); 
 
	register_post_type( 'gallery' , $args );
}
// Register "Site type" taxonomy (As Category)
register_taxonomy("Site Type", array("gallery"), 
	array(
	"hierarchical" => true, 
	"label" => "Site Type", 
	"singular_label" => "Site Type", 
	"rewrite" => true)
	);
	
//Resgister "Color" Taxonomy (As Tags)
register_taxonomy("Color", array("gallery"),
	array(
	"hierarchical" => false,
	"label" => "Color",
	"singular_label" => "Color",
	"rewrite" => true)
	);
	
//gallery post meta field for website URL or source URL	
add_action("admin_init", "admin_init");

function admin_init(){
  add_meta_box("source_url", "Source URL", "source_url", "gallery", "normal", "low");
}
 
function source_url(){
  global $post;
  $custom = get_post_custom($post->ID);
  $source_url = $custom["source_url"][0];
  ?>
  <label>source URL:</label>
  <input name="source_url" value="<?php echo $source_url; ?>" />
  <?php
}

Initial URL

                                

Initial Description

                                

Initial Title
WordPress Gallery page with custom post type and custom taxonomy

Initial Tags
post, wordpress

Initial Language
PHP