这在stackoverflow中已被多次询问,但我正在做所有事情,没有任何作用我仍然得到“糟糕!无法找到该页面。”
我有一个模板,我用链接循环CPT分类法 []
当我点击其中一个类别时,我会收到网址
http://comisionpais.com/categorias/educacion/
http://comisionpais.com/categorias/{taxonomy}
我创建了这个文件
taxonomy-comision-publicaciones.php
taxonomy.php
category-publica.php
category.php
这是我正在使用的3 CPT的代码
/****************** Custom Post Type ***************/
// Our custom post type function
function create_posttype() {
register_post_type( 'publica',
// CPT Options
array(
'labels' => array(
'name' => __( 'Publicaciones' ),
'singular_name' => __( 'Publicación' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'publicacion'),
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail' ),
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'menu_icon' => 'dashicons-book',
)
);
register_post_type( 'entrev',
// CPT Options
array(
'labels' => array(
'name' => __( 'Entrevistas' ),
'singular_name' => __( 'Entrevista' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'entrevista'),
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail' ),
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'menu_icon' => 'dashicons-video-alt3',
)
);
register_post_type( 'reco',
// CPT Options
array(
'labels' => array(
'name' => __( 'Reconocimientos' ),
'singular_name' => __( 'Reconocimiento' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'reconocimiento'),
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail' ),
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'menu_icon' => 'dashicons-awards',
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
/****** CPT Category Link ******/
function create_comision_taxonomies() {
$labels = array(
'name' => _x( 'Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Categories' ),
'all_items' => __( 'All Categories' ),
'parent_item' => __( 'Parent Category' ),
'parent_item_colon' => __( 'Parent Category:' ),
'edit_item' => __( 'Edit Category' ),
'update_item' => __( 'Update Category' ),
'add_new_item' => __( 'Add New Category' ),
'new_item_name' => __( 'New Category Name' ),
'menu_name' => __( 'Categories' ),
);
$args = array(
'hierarchical' => true, // Set this to 'false' for non-hierarchical taxonomy (like tags)
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'categorias' ),
);
register_taxonomy( 'comision-publicaciones', array( 'publica' ), $args );
register_taxonomy( 'comision-entrevistas', array( 'entrev' ), $args );
register_taxonomy( 'comision-reconocimientos', array( 'reco' ), $args );
}
add_action( 'init', 'create_comision_taxonomies', 0 );
所以我担心如果我错误地命名了文件,但是如果我使用像taxonomy.php这样的主文件名或者class.php会使用这些文件但是没有发生任何事情。 / p>