作者:手机用户2602909197 | 来源:互联网 | 2023-09-05 11:24
篇首语:本文由编程笔记#小编为大家整理,主要介绍了PHP 带有自定义帖子类型和自定义分类的WordPress图库页面相关的知识,希望对你有一定的参考价值。
//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]; ?> source URL: } ?>