具有自定义文章类型和自定义分类的WordPress库页面
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了具有自定义文章类型和自定义分类的WordPress库页面相关的知识,希望对你有一定的参考价值。
<?php //register Gallery post type add_action('init', 'gallery_register'); function gallery_register() { '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' => '' ); 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, ); register_post_type( 'gallery' , $args ); } // Register "Site type" taxonomy (As Category) "hierarchical" => true, "label" => "Site Type", "singular_label" => "Site Type", "rewrite" => true) ); //Resgister "Color" Taxonomy (As Tags) "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 } ?>
以上是关于具有自定义文章类型和自定义分类的WordPress库页面的主要内容,如果未能解决你的问题,请参考以下文章
PHP 带有自定义帖子类型和自定义分类的WordPress图库页面
在WordPress中显示具有自定义摘录长度和自定义阅读更多文本的文章