如何移除WordPress中Toolset创建的自定义文章类型URL的blog前缀?
Hey there! Let's get that permalink sorted out for your FAQ custom post type. It sounds like a mix-up between Toolset settings and rewrite rule configuration—here's how to fix it step by step:
1. Correct the Toolset Custom Post Type Settings First
Since you used Toolset to create the faq post type, its built-in settings might be overriding the code you added to functions.php. Head to your WordPress dashboard:
- Go to Toolset → Post Types
- Find your "FAQ" post type and click Edit
- Navigate to the Slug and Archives section:
- Set the Archive slug to
faq(this controls the base URL for your FAQ archive) - Under Permalink settings, uncheck the box labeled "Use the permalink structure front base (like /blog/)"—this is the visual equivalent of
with_front => falsein code
- Set the Archive slug to
- Save your changes
2. Fix Your functions.php Code (If You're Using Custom Registration)
If you're also registering the post type via code (instead of relying solely on Toolset), you had a small mistake in your rewrite array: you set slug to blog instead of faq! Update the code to this:
register_post_type( 'faq', array( // Keep your existing labels, supports, and other settings here 'rewrite' => array( 'slug' => 'faq', // This should match your desired base URL 'with_front' => false, // Avoids prepending your blog's front base 'has_archive' => true // Ensures the archive page (www.example.com/faq) works ) ) );
3. Flush WordPress Rewrite Rules
This is the most common missed step—WordPress caches rewrite rules, so changes won't take effect until you flush them:
- Go to Settings → Permalinks in your dashboard
- You don't need to change anything—just click Save Changes at the bottom. This forces WordPress to regenerate the rewrite rules.
- If that doesn't work, you can temporarily add this line to your
functions.php(remove it after visiting your site once, as it slows down page loads):flush_rewrite_rules();
4. Check for Conflicts
If the issue persists, rule out conflicts with other tools:
- Temporarily disable all non-Toolset plugins (especially SEO plugins like Yoast, which often modify permalinks)
- Switch to a default WordPress theme (like Twenty Twenty-Four) to see if your theme is overriding rewrite rules
Once you've followed these steps, your FAQ archive should load at www.example.com/faq as expected!
内容的提问来源于stack exchange,提问作者Dhilipkumar

