基本上,我的网站基于一个主题,该主题具有很多缺少的代码,而这些功能应该存在。除此以外,我已经设法整理出所有内容。
该网站有一个投资组合发布类型。本质上是在创建类别,并且可以将帖子分配给这些类别。创建了一个帖子,但是类别的存档页面返回“找不到页面”。
我的functions.php部分如下:
/** taxonomy.
--------------------------------------------------------------------------------------------------- */
function create_portfolio_taxonomy()
{
register_taxonomy(
'portfolio-category',
'portfolio',
array(
'labels' => array(
'name' => _x('Categories', 'portfolio', 'awe'),
'singular_name' => _x('Category', 'portfolio', 'awe'),
'menu_name' => __('Categories', 'awe'),
'all_items' => __('All Categories', 'awe'),
'edit_item' => __('Edit Category', 'awe'),
'view_item' => __('View Category', 'awe'),
'update_item' => __('Update Category', 'awe'),
'add_new_item' => __('Add New Category', 'awe'),
'new_item_name' => __('New Category Name', 'awe'),
'parent_item' => __('Parent Category', 'awe'),
'parent_item_colon' => __('Parent Category:', 'awe'),
'search_items' => __('Search Categories', 'awe'),
),
'show_admin_column' => true,
'hierarchical' => true,
'rewrite' => array(
'slug' => 'category',
),
)
);
}
add_action('init', 'create_portfolio_taxonomy', 0);
add_action('init', 'custom_taxonomy_flush_rewrite');
function custom_taxonomy_flush_rewrite() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
/*------------------------------------------------------------------------------------------------------------------*/
/* custom post type
/*------------------------------------------------------------------------------------------------------------------*/
add_action( 'init', 'create_portfolio_post_type' );
function create_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio' ),
'singular_name' => __( 'Portfolio' )
),
'menu_icon' => 'dashicons-portfolio',
'hierarchical' => 'true',
'public' => true,
'has_archive' => true,
)
);
}
如您所见,我可以按主页上投资组合部分中的类别进行分类-willd.co.uk/#clients
帖子页-http://willd.co.uk/portfolio/victoria-front-of-house/分类页面无效-http://willd.co.uk/category/eggs/
从我收集的资料来看,WordPress经历了潜在模板的层次结构,然后进入了archive.php
我是php的新手,所以实际上只是使用教程和逻辑来使一切正常。
我已经清除了永久链接。
[我在想,也许我需要创建和编辑一个Portfolio-archive.php或taxonomy.php文件,而不是让它落入archive.php,尽管看过教程和其他我无法做到的stackoverflow答案解决这个问题。
非常感谢您的帮助,>>
W
基本上,我的网站基于一个主题,该主题具有很多缺少的代码,而这些功能应该存在。除此以外,我已经设法整理出所有内容。该站点有一个投资组合发布...
更好地将其用于数组,您会注意到很多事情,将子弹更改为投资组合类别,我认为它现在可以使用。