簡體   English   中英

WordPress,分類頁面未鏈接

[英]WordPress, taxonomy page not linking up

我有一個名為Sectors的自定義帖子類型,它是使用以下代碼制作的:

    add_action( 'init', 'wpsites_custom_post_type' );
function wpsites_custom_post_type() {

register_post_type( 'sectors',
    array(
        'labels' => array(
            'name'          => __( 'Sectors' ),
            'singular_name' => __( 'sector' ),
        ),
        'has_archive'  => true,
        'hierarchical' => true,
        'menu_icon'    => 'dashicons-heart',
        'public'       => true,
        'rewrite'      => array( 'slug' => 'sectors', 'with_front' => false ),
        'supports'     => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes' ),
        'taxonomies'   => array( 'sectors', 'post_tag' ),
    ));

}

然后我有這段代碼,它將類別添加到扇區:

add_action( 'init', 'create_sector_cat_categories' );

function create_sector_cat_categories() {
    register_taxonomy(
        'SectorCategories',
        'sectors',
        array(
            'label' => __( 'Sector Categories' ),
            'rewrite' => array( 'slug' => 'sectorcategories' ),
            'hierarchical' => true,
        )
    );
}

因此,當我轉到我的部門頁面時,當前使用“ sectorcategories.php”頁面列出了類別。

然后,當您單擊一個扇區類別時,將使用taxonomy-sectorcategories.php顯示該類別中的所有扇區。

現在,我遇到的問題是,當我從此處單擊一個扇區時,它正在使用index.php文件,但是我有一個名為single-sectors.php的頁面設置。

有誰知道為什么它不遵循其分類法?

有時,如果您即時進行分類,則wordpress不會對其進行更新。 只需轉到您的設置>永久鏈接,然后單擊更新

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM