I’ve defined a custom post type in wordpress in this way:
add_action('init', 'register_cima_fellowship');
function register_cima_fellowship() {
$args = array(
'labels' => $labels,
'public' => true,
'menu_position'=>20,
'show_ui'=>true,
'show_in_menu'=>true,
'show_in_nav_menus' => true,
'rewrite' => array('slug' => 'fellow'),
'supports' => array('title', 'editor','thumbnail'),
'has_archive'=>true
);
register_post_type('cima_fellowship', $args);
}
I’ve created a custom archive in a file called archive-cima_fellowship.php
and it works, showing all my cpt.
This cpt have a meta attribute like status, to define some of them as current and other as past. I would like to have two different archive pages, one to show only he current and another to show only the past.
For now I turn around this using a get variable in this way mysite.com/cima_fellowship/?type=past
But I would like to have cleaner url like mysite.com/fellows/past
.
For this I defined 'rewrite' => array('slug' => 'fellow'),
in the registration of the cpt, but I can’t access the archive page trough `mysite.com/fellows
, I still have to visit ‘mysite.com/cima_fellowship/’, and I can’t find out how to “style” the URL.
Any suggestion? tutorial? guide?
Thanks in advance!
Now I am not 100% sure if this will work but try adding:
So you would have:
I had a similar problem 10 or so months ago and I add this and seemed to fix my problem.
This is an issue with WordPress, so long as you have the ‘slug’ => ‘my-slug’ argument it will work but you have to first change your permalink structure. Change your permalinks via WorkPress>Settings>Permalinks to a random different structure then back to your previous one.
This should fix the issue.