我在发布这篇文章时发现了这个问题,但我花了很长时间才找到大量“刷新永久链接”的答案。
<?php
add_action( \'init\', \'mytheme_create_post_type\' );
function mytheme_create_post_type() { // jobs custom post type
// set up labels
$job_labels = array(
\'name\' => __( \'Jobs\' ),
\'singular_name\' => __( \'Job\' ),
\'add_new\' => __( \'Add New\' ),
\'add_new_item\' => __( \'Add New Job\' ),
\'edit_item\' => __( \'Edit Job\' ),
\'new_item\' => __( \'New Job\' ),
\'all_items\' => __( \'All Jobs\' ),
\'view_item\' => __( \'View Job\' ),
\'search_items\' => __( \'Search Jobs\' ),
\'not_found\' => __( \'No Jobs Found\' ),
\'not_found_in_trash\' => __( \'No Jobs found in Trash\' ),
\'parent_item\' => __( \'Parent Job\' ),
\'parent_item_colon\' => __( \'Parent Job:\' ),
\'menu_name\' => __( \'Jobs\' ),
);
register_post_type(
\'job\',
array(
\'labels\' => $job_labels,
\'has_archive\' => true,
\'public\' => true,
\'hierarchical\' => false,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'custom-fields\', \'thumbnail\', \'page-attributes\' ),
\'taxonomies\' => array( \'post_tag\', \'job_category\' ),
\'exclude_from_search\' => true,
\'capability_type\' => \'post\'
)
);
register_taxonomy_for_object_type( \'job_category\', \'job\' );
}
add_action( \'init\', \'mytheme_create_taxonomies\', 5 );
function mytheme_create_taxonomies() {
// job taxonomy
$job_labels = array(
\'name\' => _x( \'Job Categories\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Job Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Job Categories\' ),
\'all_items\' => __( \'All Job Categories\' ),
\'parent_item\' => __( \'Parent Job Category\' ),
\'parent_item_colon\' => __( \'Parent Job Category:\' ),
\'edit_item\' => __( \'Edit Job Category\' ),
\'update_item\' => __( \'Update Job Category\' ),
\'add_new_item\' => __( \'Add New Job Category\' ),
\'new_item_name\' => __( \'New Job Category\' ),
\'menu_name\' => __( \'Job Categories\' ),
);
register_taxonomy(
\'job_category\',
\'job\',
array(
\'hierarchical\' => false,
\'labels\' => $job_labels,
\'rewrite\' => false,
\'show_admin_column\' => true
)
);
}
考虑到permalinks的问题,我把所有的东西都关掉了。我会将Settings>Permalinks设置为默认值并设置
rewrite => false
对于post类型和分类法。
但是,在创建一个包含HR类别的工作后http://www.example.com/?job_category=hr 给了我一个“抱歉,没有找到结果”,即不是404,但该类别没有结果。