2015-09-08 53 views
0

我想刪除wordpress永久鏈接中特定自定義帖子的類別基地。我使用WP No Category Base插件,但這是爲所有人工作。刪除類別基地的單個自定義帖子類型

+1

檢查,希望它可以幫助你:http://wpgarage.com/code-snippets/remove-permalink-base-custom-post-type-slug/ –

+1

請不要標記您的問題作爲緊急的 - 詳細,經過深入研究的問題應該在適當的時候獲得答覆。我將添加'php'標籤。 – halfer

+0

請參閱https://codex.wordpress.org/Function_Reference/register_post_type#rewrite –

回答

0

你可以嘗試這段代碼從url中刪除任何自定義分類的基地。 把它放在你的functions.php或你的插件主文件中。這裏

function sr_remove_cat_base($link, $term, $taxonomy) 
{ 
    // Name of your custom taxonomy (category) 
    if ($taxonomy !== 'custom_tax') // Don't do anything if not our cpt taxonomy 
     return $link;     

    // Slug of your custom taxonomy (category) 
    return str_replace('custom-tax/', '', $link); // Remove the base 
} 
add_filter('term_link', 'sr_remove_cat_base', 10, 3); 
相關問題