Hi @ajisimplifymecom,
There doesn’t seem to be a problem with the example code you shared. Can you give us more information about what error you’re seeing related to Yoast SEO?
It’s a bit out of our scope to troubleshoot custom code, but it may help to check the Yoast developer documentation.
If you’re not familiar with what custom code to add or how to use WordPress hooks, we highly recommend contacting a web developer. You can also check out sites like Codeable.io for available freelance WordPress developers.
Thread Starter
AJ
(@ajisimplifymecom)
When multiple taxonomies are selected and a primary taxonomy is defined, this script used to pull the primary taxonomy. Now it pulls the first in the array based on the title’s alphabetical order.
@ajisimplifymecom Thanks for your reply.
Unfortunately we can’t offer support on custom code. Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes. Maybe someone watching these forums can assist you further, but if your topic is inactive for 7 days, we’ll mark it as resolved to keep the overview.
Thread Starter
AJ
(@ajisimplifymecom)
understood. are you able to point me to some documentation that explains how to access the primary taxonomy for a given post?
Thread Starter
AJ
(@ajisimplifymecom)
Hi all! I’ve discovered the issue.
When two or more taxonomies are selected, the primary taxonomy drop down menu appears. Yoast populates this dropdown with the selected taxonomies in the order they were selected. If a user were to select the intended primary taxonomy first, it would be the first to appear in the list, creating the illusion it has been selected, when in fact, no primary taxonomy was selected.
A potential remedy here would be to add some kind of initial entry, like and empty option or an option that says “Select a primary _taxonomy_name_”
Thanks for the help!
Hi @ajisimplifymecom
We tried to use the primary category feature on a test site in Yoast SEO v16.4. We created a new post, ticked the first category, and the moment we ticked the second category, the primary category drop-down then appears. It automatically selects the first category that was ticked and sets it as the primary category. We then published the post and we do see that the primary category feature is working as intended as it includes the set primary category in the permalinks (since the permalink structure was set to /%category/%postname%/), so it does seem to be working as expected.
If you mean that the primary category isn’t working relative to your custom code that looks up the primary category, then we apologize if we can’t be of much more assistance. You can refer to the documentation here, or if there’s a valid bug, you can raise a bug report here.
We are going ahead and marking this issue as resolved due to inactivity. If you require any further assistance please create a new issue.