【问题标题】:Custom post permalink redirects to homepage自定义帖子永久链接重定向到主页
【发布时间】:2017-06-10 10:52:21
【问题描述】:

自定义帖子永久链接重定向到主页。

当点击管理员的永久链接时,网址会重定向到主页。

还有单{post type}.php 也不行。

请帮忙!

function fovit_events_post_type() 
{
    $labels = array(
        'name'                  => __('Events','mfn-opts'),
        'singular_name'         => __('Events','mfn-opts'),
        'add_new'               => __('Add New','mfn-opts'),
        'add_new_item'          => __('Add New Events','mfn-opts'),
        'edit_item'             => __('Edit Events','mfn-opts'),
        'new_item'              => __('New Events','mfn-opts'),
        'view_item'             => __('View Events','mfn-opts'),
        'search_items'          => __('Search Events','mfn-opts'),
        'not_found'             => __('No events found','mfn-opts'),
        'not_found_in_trash'    => __('No events found in Trash','mfn-opts'), 
        'parent_item_colon'     => ''
      );

    $args = array(
        'labels'                => $labels,
        'menu_icon'             => 'dashicons-controls-volumeon',
        'public'                => true,
        'publicly_queryable'    => true,
        'show_ui'               => true, 
        'query_var'             => true,
        'capability_type'       => 'post',
        'hierarchical'          => false,
        'menu_position'         => null,
        'rewrite'               => array( 'slug' => $events_item_slug, 'with_front'=>true ),
        'supports'              => array( 'title','thumbnail','editor' ),
    ); 

    register_post_type( 'events', $args );

    register_taxonomy( 'events-types', 'events', array(
        'hierarchical'          => true,
        'label'                 =>  __('Event categories','mfn-opts'),
        'singular_label'        =>  __('Event category','mfn-opts'),
        /*'rewrite'             => true,*/
        'query_var'             => true
    ));
}
}
add_action( 'init', 'fovit_events_post_type' );

【问题讨论】:

    标签: php wordpress permalinks


    【解决方案1】:

    转到设置 -> 永久链接并重新更新结构永久链接。

    【讨论】: