register custom post type網址
-
使用register custome post type註冊一個post type後,
例如新增一個 production的post type,如果有一篇文章的ID為12345其post type為production
那在網址列上基本上輸入http://XXXX/12345
應該會被導到single-production.php這個頁面
並顯示12345這篇文章內容,但是基本上這樣是可以正常運行。
不過卻有一個問題是:需要登入。
如果沒有登入,就輸入http://XXXX/12345 那會回傳沒有此頁面。
反之則會自動導回正確的12345這篇文章內容。
基本上看起來是權限的問題,但是該怎麼去解決呢?
add_action( ‘init’, ‘create_post_type’ );
function create_post_type() {
register_post_type( ‘production’,
array(
‘labels’ => array(
‘name’ => __( ‘production’ ),
‘singular_name’ => __( ‘production’ )
),
‘public’ => true,
‘has_archive’ => true,
‘rewrite’ => false
)
);
}
正在檢視 2 則回覆 - 1 至 2 (共計 2 則)
正在檢視 2 則回覆 - 1 至 2 (共計 2 則)
- The topic ‘register custom post type網址’ is closed to new replies.