1
我想創建一個非常特定類型的自定義帖子類型,一個不應允許用戶搜索使用此類帖子創建的其他帖子,但只允許他們看到他們被髮送到訪問鏈接。我到目前爲止是這樣的:在Wordpress中自定義帖子類型不可搜索
function pp_register_post_type(){
$labels = array(
'name' => _x('Viajes', 'post type general name', 'negocios'),
'singular_name' => _x('Viajes', 'post type singular name', 'negocios'),
'menu_name' => _x('Viajes', 'admin menu', 'negocios'),
'name_admin_bar' => _x('Viajes', 'add new on admin bar', 'negocios'),
'add_new' => _x('Add New', 'Viajes', 'negocios'),
'add_new_item' => __('Add New Viajes', 'negocios'),
);
$args = array(
'labels' => $labels,
'description' => __('Description.', 'negocios'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'Viajes'),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'),
'menu_icon' => 'dashicons-welcome-write-blog'
);
register_post_type('pp_portfolio', $args);
}
add_action('init', 'pp_register_post_type');
我想設置'publicly_queryable' => true,
爲false會做,但它反而是在創建後時,不註冊一個固定鏈接什麼。然後,當我嘗試查看帖子時,它只是將我發送到主頁。
我該如何設置$args
以避免archive.php按日期或其他查詢顯示帖子列表?當有人試圖搜索這些帖子類型時,我實際上想要輸出一個404頁面。我怎麼能解決這個問題?
非常感謝!我不知道我是如何錯過的。 – Agustin