我注册了一个自定义帖子类型,如下所示:-
/**
* Register Add Job
*
*/
add_action( \'init\', \'rv_jobs_cpt\' );
function rv_jobs_cpt() {
$labels = array(
\'name\' => _x( \'Jobs\', \'post type general name\', \'engwp\' ),
\'singular_name\' => _x( \'Jobs\', \'post type singular name\', \'engwp\' ),
\'menu_name\' => _x( \'Jobs\', \'admin menu\', \'engwp\' ),
\'name_admin_bar\' => _x( \'Jobs\', \'add new on admin bar\', \'engwp\' ),
\'add_new\' => _x( \'Add New Job\', \'Property\', \'engwp\' ),
\'add_new_item\' => __( \'Add New Job\', \'engwp\' ),
\'new_item\' => __( \'New Job\', \'engwp\' ),
\'edit_item\' => __( \'Edit Job\', \'engwp\' ),
\'view_item\' => __( \'View Jobs\', \'engwp\' ),
\'all_items\' => __( \'All Jobs\', \'engwp\' ),
\'search_items\' => __( \'Search Jobs\', \'engwp\' ),
\'parent_item_colon\' => __( \'Parent Jobs:\', \'engwp\' ),
\'not_found\' => __( \'No Jobs found.\', \'engwp\' ),
\'not_found_in_trash\' => __( \'No Jobs found in Trash.\', \'engwp\' )
);
$args = array(
\'description\' => __( \'Jobs\', \'engwp\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'trackbacks\', \'custom-fields\', \'comments\', \'revisions\' ),
\'taxonomies\' => array( \'category\', \'post_tag\' ),
\'hierarchical\' => false,
\'public\' => true,
\'publicly_queryable\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'jobs\' ),
\'show_ui\' => true,
\'menu_icon\' => \'dashicons-universal-access-alt\',
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 31,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'capability_type\' => \'post\',
);
register_post_type( \'jobs\', $args );
}
然后,我使用ACF Pro填充此帖子类型的自定义字段。其中两个自定义字段是
Job Sector 和
Job Location我有一个求职工具,它使用主页上的一个表单,使用POST方法重定向到/jobs/(archive jobs.php)。然后,我使用WP\\u Query根据搜索参数显示作业。
虽然这是可行的,但我现在需要根据他们的搜索更改URL。例如,如果有人要搜索金融工作,URL必须是:/jobs/Finance,或者/jobs/marketing,如果他们要搜索Marketings工作。
如果他们选择“财务”作为工作类型,同时选择“诺丁汉”作为位置,那么URL将需要变成/jobs/finance/in-nottingham
这可能吗?因为如果您现在要访问这些页面,这些页面只会转到404页面,而为每种不同类型的变体创建归档页面是没有意义的。
任何帮助都将不胜感激,提前感谢!
编辑:
完整的结构如下:-
/jobs/finance
/jobs/hr
/jobs/procurement
/jobs/marketing
/jobs/office-support
/jobs/finance/in-nottingham
/jobs/finance/in-leicester
/jobs/finance/in-derby
/jobs/finance/in-lincoln
/jobs/hr/in-nottingham
/jobs/hr/in-leicester
/jobs/hr/in-derby
/jobs/hr/in-lincoln
/jobs/procurement/in-nottingham
/jobs/procurement/in-leicester
/jobs/procurement/in-derby
/jobs/procurement/in-lincoln
/jobs/marketing/in-nottingham
/jobs/marketing/in-leicester
/jobs/marketing/in-derby
/jobs/marketing/in-lincoln
/jobs/office-support/in-nottingham
/jobs/office-support/in-leicester
/jobs/office-support/in-derby
/jobs/office-support/in-lincoln
/jobs/leicester
/jobs/nottingham
/jobs/derby
/jobs/lincoln
/jobs/other
/jobs/international