我有一個註冊分類(wps_type)和2個自定義帖子類型(wps_business,wps_location)的順序。已註冊的分類將重寫arg設置爲slug => type,並且帖子類型具有slug =>業務& slug =>位置已設置。我需要一個自定義智能固定鏈接重寫規則,其中以下所有內容都可用。自定義WordPress自定義發佈類型和自定義分類標準重寫保持默認存檔
默認工作(仍然需要努力):
http://domain.com/post-type/post-name => http://domain.com/business/post-name
http://domain.com/post-type/post-name => http://domain.com/location/post-name
http://domain.com/taxonomy/term-name => http://domain.com/type/term-name
但我需要的是:
http://domain.com/post-type/taxonomy => http://domain.com/location-post-name/type-term-name
所以我相信使用post_type_link過濾器可能無法正常工作,但我可能是錯的。下面是一些代碼,我試過:
add_rewrite_rule('^directory/([^/]*)/([^/]*)/?', 'index.php?wps_location=$matches[1]&wps_business=$matches[2]', 'top');
add_rewrite_tag('%wps_location%', '([^/]+)');
add_rewrite_tag('%wps_business_types%', '([^&]+)');