最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

custom taxonamy and post type

programmeradmin2浏览0评论

I have a little problem with showing of my taxonomy template my codes to create custom post type are:

    function setup_projects_cpt(){
    $labels = array(
        'name' => esc_html_x('Projects','teklan'),
        'singular_name' => esc_html_x('Project', 'post type singular name' , 'teklan'),
        'add_new' => esc_html_x('Add New', 'Project','teklan'),
        'add_new_item' => esc_html__('Add New Project'),
        'edit_item' => esc_html__('Edit Project'),
        'new_item' => esc_html__('New Project'),
        'all_items' => esc_html__('All Projects'),
        'view_item' => esc_html__('View Project'),
        'search_items' => esc_html__('Search Projects'),
        'not_found' => esc_html__('No Projects Found'),
        'not_found_in_trash' => esc_html__('No Projects found in the trash'),
        'parent_item_colon' => '',
        'menu_name' => 'Projects'
    );
    $args = array(
        'labels' => $labels,
        'description' => 'My Projects',
        'publicly_queryable'=>true,
        'rewrite' => array('slug' => 'projects'),
        'public' => true,
        'menu_position' => 5,
        'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'),
        'has_archive' => true,
        'taxonomies' => array(''),
        'menu_icon' => 'dashicons-admin-multisite',  /
    );
    register_post_type('projects', $args);
}
add_action('init', 'setup_projects_cpt');


function projects_taxonomy() {
    register_taxonomy(
        'project_categories', 
        'projects',       
        array(
            'hierarchical' => true,
            'label' => 'Project Categories',  
            'query_var' => true,
            'rewrite' => array(
                'slug' => 'projects', 
                'with_front' => false 
            )
        )
    );
}
add_action( 'init', 'projects_taxonomy');

i've created projects a,b ,c , ... and placed them in category cat1 , cat2 , ... files for template are(in theme folder):

single-projects.php archive-projects.php

when i click on category term in dashboard admin i'd get 404 error .

site/projects --> is okay and shows all my projects as i want site.cem/project/a --> is okay and shows single projects content site/projects/cat1 --> 404 error !!! how can i solve these problem?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论