I have a custom post type:
register_post_type( 'tour',
[
'labels' => [
'name' => __( 'Tour shows' ),
'singular_name' => __( 'Tour show' )
],
'public' => true,
'menu_icon' => 'dashicons-tickets-alt',
'has_archive' => 'tour', // also tried true
'with_front' => true,
'exclude_from_search' => true,
'taxonomies' => ['post_tag'],
'rewrite' => ['slug' => 'shows-on-tour'],
'supports' => ['title', 'editor', 'thumbnail']
]
);
(this has been butchered a bit while trying to make it work)
I’m having an issue where by when I do get_permalink($tour->ID)
it returns:
example.com/post-title
This then redirects you to
example.com/shows-on-tour/post-title
The problem is I have a separate post type for “shows not on tour”, so whenever I link to:
example.com/post-title
I end up at:
example.com/shows-not-on-tour/post-title
How can I use get_permalink
on either post type and have it return the full url to the post with the correct post type on the front?
Update
In the editor, when I edit the tour it clearly says:
example.com/shows-on-tour/post-title
and the not on tour:
example.com/shows-not-on-tour/post-title
So the issue must lie with how / where I’m calling get_permalink
.