あなたはカスタムタクソノミをポストスラッグに書き換えるのを忘れたと思います。
これをあなたのregister_post_type
に書いてください。
'rewrite' => array('slug' => 'product-type')
今、あなたはあなたが教えてくれているので、WordPressのページまたはポストとそれに一致するようにしようとしますので、今、カスタムポストタイプのスラッグを削除したとして、あなたのカスタム製品
/**
* Remove the slug from published post permalinks.
*/
function custom_remove_cpt_slug($post_link, $post, $leavename)
{
if ('product-type' != $post->post_type || 'publish' != $post->post_status)
{
return $post_link;
}
$post_link = str_replace('/' . $post->post_type . '/', '/', $post_link);
return $post_link;
}
add_filter('post_type_link', 'custom_remove_cpt_slug', 10, 3);
からproduct-type
スラグを削除する必要がありますあなたのカスタム投稿タイプのURLもチェックするWP。だから、そのためにこれを使用します。
は
function custom_parse_request_tricksy($query)
{
// Only noop the main query
if (!$query->is_main_query())
return;
// Only noop our very specific rewrite rule match
if (2 != count($query->query) || !isset($query->query['page']))
{
return;
}
// 'name' will be set if post permalinks are just post_name, otherwise the page rule will match
if (!empty($query->query['name']))
{
$query->set('post_type', array('post', 'product-type', 'page'));
}
}
add_action('pre_get_posts', 'custom_parse_request_tricksy');
参考:Remove The Slugs from Custom Post Type URL
ホープ、このことができます!
私の単一の製品URLはhttp://www.naturesbioscience.com/product/vascuvite/で、製品カテゴリurlはhttp://www.naturesbioscience.com/です。製品タイプ/免疫支援補助剤/。私は、製品カテゴリのURLから製品タイプ(タクソノミ)を削除する必要があります。 – InsightCoders