In the site I’m building there is a post-type called “Focus”. Since they need to url to be like www.mysite.com/focus/page-post-name
I have the post type slug as “focus”.
Of course the archive page is www.mysite.com/focus
this is causing an issue since I need a specific page to be an archive page. Meta boxes are used to build and add settings to pages. I can’t just create a page called “Focus” since that is reserved by the post-type.
My idea is to create a page called “Our Focus” resulting a URL of www.mysite.com/our-focus
.
I’d like to just remove the “our-” from that url to make it appear that the archive is being used.
I’ve tried setting has_archive to false but that just reverts to using the archive.php page.
2 Answers
You can add the following to your .htaccess
file in between the <IfModule mod_rewrite.c>
tags:
RewriteCond %{HTTP_HOST}
RewriteRule ^our-focus/(.*)$ /focus/$1 [R=301,L]
Your .htaccess
should looks like the following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Custom Rewrite
RewriteCond %{HTTP_HOST}
RewriteRule ^our-focus/(.*)$ /focus/$1 [R=301,L]
</IfModule>
# END WordPress
As a result it will do the following:
http://example.com/our-focus/test
Redirects to:
http://example.com/focus/test