The yoast breadcrumb plugin auto links to the custom post type archive page but because I have set a custom URL for the post type I am getting a 400 error on the index link e.g. hidden link.
I've tried applying a 301 redirect at server level but this doesn't appear to resolve the issue. How can I stop this issue occuring so I can link to the relevant archive / index page?
Hello and thank you for contacting the Toolset support.
Can you elaborate more on I have set a custom URL for the post type? Did you do it using custom code? Using a 3rd party plugin?
Can you share the URL of the archive page or a page where these erroneous links exist? I would like to know more about this issue.
In the meantime, when you change the permalinks structure using the add_permastruct you will also need to add a filter to change the link of posts using the filter. Check this SO reply https://wordpress.stackexchange.com/a/253325
- https://developer.wordpress.org/reference/functions/add_permastruct/
- https://developer.wordpress.org/reference/hooks/post_type_link/
Finally, I would like to know, what permalink structure do you want to have? Or if you need the Yoast generated links to be different?
Hey Jamal
Appreciate the response.
Let me try to address your questions:
- I amended the permalink using the option within the custom post setup options in toolset. For example rather than 'Players' having a permalink of ../player/[player name] it becomes ../player/[post-id]/[player name]
- The actual player permalinks work fine (e.g. hidden link) as does the index if I go to hidden link but for some reason the yoast breadcrumbs URL for the index defaults to hidden link (you see this live on the text above 'Alyssa Valdez' h1 on hidden link.
I think perhaps it is the filter that you referenced that I am perhaps missing.
If I understand well, you are talking about the link "Players", right? This one hidden link right?
It seems to me that this comes from the Yoast plugin, Toolset is not involved in the generation of that link. So, I'll suggest that you reach to the Yoast team to report this issue.
From our side, we can suggest a Javascript workaround. Add the following snippet to your website. Or, if you are using a content template for Players, add it to the content template. It will remove the "%post_id%/" from the link:
jQuery(function($){
$('#breadcrumbs a').attr('href', $('#breadcrumbs a').attr('href').replace('%post_id%/', ''))
})
I hope this helps. Let me know if you have any questions.
My issue is resolved now. Thank you!