지원 » Developing with WordPress Forum » Custom post type & custom taxonomy page load

  • Hi,

    I made and checked the post type page archive-videos.php. However, I created taxonomy-videos.php to load the page registered in the added taxonomy, but the page could not be found. What was the solution?

    my source here

    add_action( 'init', 'set_rs_custom_posts' );
    function set_rs_custom_posts() {
        $news_label = array(
            'name'               => __('News', 'rsupport' ),
            'singular_name'      => __('News', 'rsupport' ),
            'menu_name'          => __('News', 'rsupport'),
            'show_in_nav_menus' => true,
            'show_in_menu' => true,
        );
    
        $news = array(
            'labels'        => $news_label,
            'description'   => __('news', 'rsupport'),
            'public'        => true,
            'menu_position' => 5,
            'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'page-attributes'),
            'has_archive'   => true, // only this is required to enable archive page else 404 error will occur
            'publicly_queryable' => true,
            'show_ui' => true,
            'query_var' => true,
            'hierarchical' => false,
            // 'taxonomies'  => array( 'news', 'news-category' ),
            
        );
        $video_label = array(
            'name'               => __('Video', 'rsupport' ),
            'singular_name'      => __('Video', 'rsupport' ),
            'menu_name'          => __('Video', 'rsupport'),
            'show_in_nav_menus' => true,
            'show_in_menu' => true,
        );
    
        $video = array(
            'labels'        => $video_label,
            'description'   => __('video', 'rsupport'),
            'public'        => true,
            'menu_position' => 5,
            'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'page-attributes'),
            'has_archive'   => true, // only this is required to enable archive page else 404 error will occur
            'publicly_queryable' => true,
            'show_ui' => true,
            'query_var' => true,
            'hierarchical' => false,
            'taxonomies' => array('videos'),
            // 'rewrite' => true,
            'rewrite' => array( 'slug' => 'videos','with_front' => false),
        );
    
        // //register_post_type( 'video', $video );
        // register_post_type( 'videoguide', $video );
        register_post_type( 'videos', $video );
        register_post_type( 'news', $news );
    
        flush_rewrite_rules();
    }
    
    add_action( 'init', 'set_rs_custom_categories' );
    function set_rs_custom_categories(){
        $taxonomy_labels = array(
            'name'                       => _x( 'Category', 'Taxonomy General Name', 'rsupport' ),
            'singular_name'              => _x( 'Category', 'Taxonomy Singular Name', 'rsupport' ),
            'menu_name'                  => __( 'Category', 'rsupport' ),
            'all_items'                  => __( 'All Items', 'rsupport' ),
            'parent_item'                => __( 'Parent Item', 'rsupport' ),
            'parent_item_colon'          => __( 'Parent Item:', 'rsupport' ),
            'new_item_name'              => __( 'New Item Name', 'rsupport' ),
            'add_new_item'               => __( 'Add New Item', 'rsupport' ),
            'edit_item'                  => __( 'Edit Item', 'rsupport' ),
            'update_item'                => __( 'Update Item', 'rsupport' ),
            'separate_items_with_commas' => __( 'Separate items with commas', 'rsupport' ),
            'search_items'               => __( 'Search Items', 'rsupport' ),
            'add_or_remove_items'        => __( 'Add or remove items', 'rsupport' ),
            'choose_from_most_used'      => __( 'Choose from the most used items', 'rsupport' ),
            'not_found'                  => __( 'Not Found', 'rsupport' ),
        );
    
        $args_news = array(
            'labels'                     => $taxonomy_labels,
            'hierarchical'               => true,
            'public'                     => true,
            'show_ui'                    => true,
            'show_admin_column'          => true,
            'show_in_nav_menus'          => true,
            'show_tagcloud'              => true,
            'query_var'                  =>true,
            'has_archive'                => true,
            'rewrite' => array( 'slug' => 'news'),
        );
        $args_videos = array(
            'labels'                     => $taxonomy_labels,
            'hierarchical'               => true,
            'public'                     => true,
            'show_ui'                    => true,
            'show_admin_column'          => true,
            'show_in_nav_menus'          => true,
            'show_tagcloud'              => true,
            'query_var'                  =>true,
            'has_archive'                => true,
            'rewrite' => array( 'slug' => 'videos','with_front' => false),
        );
    
        register_taxonomy( 'news', 'news', $args_news );
        register_taxonomy( 'videos', 'videos', $args_videos );
        
    }
    
    add_action( 'init', 'set_rs_custom_register_taxonomy' );
    function set_rs_custom_register_taxonomy() {
        register_taxonomy_for_object_type( 'news', 'news' );
        register_taxonomy_for_object_type( 'videos', 'videos' );
        
    }
1 답변 보임 - 1 에서 1까지 (총 1중에서)
  • 토론글 시작자 gnjang

    (@gnjang)

    I want to create some file and control several categories in the generated file

1 답변 보임 - 1 에서 1까지 (총 1중에서)
  • ‘Custom post type & custom taxonomy page load’ 주제는 새로운 답변에 대해 닫혀있습니다.