我想在我的網站上添加一個包含照片的部分。照片應該在分類法和custom_post_types的幫助下分組。鏈接應該像 WordPress的分類和術語模板(404)
我在functions.php
創建分類和custom_post_type這
mysite.com/photography
=>分類模板mysite.com/photography/underwater
=>分類項模板,這裏是代碼。function photos_custom_post_type() { $labels = array( 'name' => __('Photos'), 'singular_name' => __('Photo'), 'menu_name' => __('Photos'), 'parent_item_colon' => __('Parent Photo'), 'all_items' => __('All Photos'), 'view_item' => __('View Photo'), 'add_new_item' => __('Add New Photo'), 'add_new' => __('Add New'), 'edit_item' => __('Edit Photo'), 'update_item' => __('Update Photo'), 'search_items' => __('Search Photo'), 'not_found' => __('Not Found'), 'not_found_in_trash' => __('Not found in Trash') ); $args = array( 'label' => __('photos'), 'description' => __('Best Photos'), 'labels' => $labels, 'supports' => array('title','thumbnail',), 'public' => true, 'hierarchical' => false, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'has_archive' => true, 'can_export' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'post', 'taxonomies' => array('post_tag') ); register_post_type('photos', $args); } add_action('init', 'photos_custom_post_type', 0); // creating Taxonomy for Custom Post Type add_action('init', 'photos_custom_taxonomy', 0); function photos_custom_taxonomy() { $labels = array( 'name' => _x('Photos Category', 'taxonomy general name'), 'singular_name' => _x('Photos Category', 'taxonomy singular name'), 'search_items' => __('Search Photos Category'), 'all_items' => __('All Photos Category'), 'parent_item' => __('Parent Photos Category'), 'parent_item_colon' => __('Parent Photos Category:'), 'edit_item' => __('Edit Photos Category'), 'update_item' => __('Update Photos Category'), 'add_new_item' => __('Add New Photos Category'), 'new_item_name' => __('New Photos Category Name'), 'menu_name' => __('Photos Category'), ); register_taxonomy('photos_cat',array('photos'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'rewrite' => array('slug' => 'photography', 'with_front' => false) )); }
我還創建
taxonomy-post_cat-underwater.php
=>這部作品taxonomy-post_cat.php
=>這並不
當我去
mysite.com/photography/underwater
=>一切正常,但是當我去mysite.com/photography
=>我得到404錯誤..請幫我理解發生了什麼問題。
在wp-config.php中設置WP_DEBUG = true。什麼是錯誤信息? – elicohenator
@elicohenator沒有錯誤,只有404頁 – CroaToa