创建了名为members的自定义帖子类型,不需要members permalink,但需要链接到成员专利,如果成员存在的话(我已经弄明白了)。
我面临的问题是ep_mask
并在此处重写端点。
基本上,我创建了一个名为“John Doe”的成员,现在希望url是这样的,用于显示他的专利:
/成员/john doe/专利
但我现在有了这样的东西:成员/约翰·多伊/?专利
我如何摆脱?
在url中标记?
register_post_type(\'team_member\', array(
\'description\' => __(\'Team Members\'),
\'label\' => __(\'team_members\'),
\'labels\' => array(
\'name\' => _x(\'Team Member\', \'Post Type General Name\'),
\'singular_name\' => _x(\'Team Member\', \'Post Type Singular Name\'),
\'menu_name\' => __(\'Team Members\'),
\'parent_item_colon\' => __(\'Parent Team Member\'),
\'all_items\' => __(\'All Team Members\'),
\'view_item\' => __(\'View Team Member\'),
\'add_new_item\' => __(\'Add New Team Member\'),
\'add_new\' => __(\'Add New\'),
\'edit_item\' => __(\'Edit Team Member\'),
\'update_item\' => __(\'Update Team Member\'),
\'search_items\' => __(\'Search Team Members\'),
\'not_found\' => __(\'Not Found\'),
\'not_found_in_trash\' => __(\'Not Found in Trash\')
),
\'taxonomies\' => array(\'department\', \'team\'),
\'supports\' => array(\'title\', \'editor\', \'thumbnail\'),
\'rewrite\' => array(\'slug\' => \'member\', \'ep_mask\' => \'patents\'),
\'hierarchical\' => false,
\'public\' => false,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => false,
\'show_in_admin_bar\' => true,
\'query_var\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => false,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\'
)
);
add_filter( \'request\', \'filter_request\' );
function filter_request($vars)
{
if(isset($vars[\'patents\']))
$vars[\'patents\'] = true;
return $vars;
}
add_action( \'template_redirect\', \'catch_vars\' );
function catch_vars()
{
global $wp_query;
if (!isset($wp_query->query_vars[\'patents\']) || !is_singular())
return;
// Template here for Member Specific Patents!
include_once(dirname(__FILE__) . \'/single-team_member-patents.php\');
exit;
}
如何使端点成为文件夹结构而不是
?
是否以查询字符串结尾?
EDIT
我在
init
行动还包括:
function do_stuff() {
add_rewrite_endpoint(\'patents\', EP_PERMALINK);
}
add_action(\'init\', \'do_stuff\');