Here are the steps to create the issue
1) Start with a clean wp install
2) Add this code to the functions.php of the 20-20 theme. I uploaded it into pastebin as the code block here has issues. Sorry about that.
https://pastebin.com/7PYeuuEs
3) Activate the theme and then the yoast seo plugin.
4) in the Yoast breadcrumb settings set the Portfolio Single breadcrumb setting to the portfolio category and set the Archive breadcrumb setting to portfolio. See image https://share.getcloudapp.com/5zujqpdq
5) Create a portfolio item with one category and the yoast [wpseo_breadcrumb] shortcode in the content, publish the post.
6) Goto the permalinks settings and set the permalink for the Portfolio single page base to f.e. Albums. save the permalinks settings
7) Now goto the single portfolio post and view it in the front of your website. Notice the portfolio in the breadcrumbs points to albums. see image
https://share.getcloudapp.com/2NubDKP2
8) Go back to the permalinks and change the Albums into albums-new or what ever you like. But not the same as albums.
9) Go back to view the Single portfolio post. You will see that the link in the portfolio archive in the breadcrumbs path has not updated and is still pointing to the wrong albums url and not albums-new.
https://share.getcloudapp.com/jkuAk10p
10) view the category page for the category you created. You will notice that also that url for the portfolio archive page is pointing to the wrong url. It never gets updated anymore after the first saving of the permalinks. See image
https://share.getcloudapp.com/8LuqKxNm
Please tell me how to fix this? Thank you
Note: The above code works. I tested it 3 times now before submitting it to you. The code i added to the functions.php of the 20-20 theme is also available on paste bin for you by this link
https://pastebin.com/7PYeuuEs
The full functions.php from the 20-20 theme with the code can be found here https://pastebin.com/3S0Pq0cj
Please let me know how to resolve this
If i use the all in one seo plugin there is not a single issue. The portfolio archive url in the breadcrumbs path follows every permalink update. I can change it to anything and it is always ok.
Thank you for your time and understanding.
Hello again @neo2k23
I’m testing this on a fresh install of WordPress up to step 5. And I have the breadcrumb path as I’d expect – Home » Portfolio » Animals » Iguana. See screenshot. Portfolio in the path links to the portfolio archive page.
But step 6 confused me; you mentioned setting the portfolio single page base to albums in the permalink setting. I’d expect that to be set to portfolio as my WordPress setup even auto-suggests. See the screenshot. What is albums? A page, a post, an archive page, a portfolio category? albums hasn’t been mentioned up until now.
Can you clarify?
Hi @maybellyne
The whole idear behind permalinks is that users can change ‘portfolio’ into what they believe it should be in any language: F.e. ‘mijn-werk’, ‘mijn-portfolio’, etc etc. They don’t want to stick to ‘portfolio’. especially in Russian or Asian countries where they have a complete different character set. But also in my own language which is probably the same as yours i want it wo say “mijn-werk”, or “onze-referenties”. That is the whole idear behind permalinks.
Otherwise why would we offer the option in the permalinks if we all want it to be ‘portfolio’? That does not make any sense then to add such setting into the wordpress permalinks. 😉
It should be customizable into any language. The portfolio type stays the same, but the permalink and archive url changes into their own language.
Since you already viewed the single portfolio item the database now already contains the archive-portfolio-type set to ‘portfolio’.
try and change the permalink now 2 x to 1) albums, and 2) my-work. You will see that in the single post and category permalink in the breadcrumbs path for the portfolio archive page will not update you will see that it still points to “portfolio”. But the url in the browser does!
View after each change of the permalink the single portfolio post in the frontend. The breadcrumbs link for portfolio archives is not matching anymore the permalink setting. Look at the url in the browser path for the single portfolio item. It has the correct permalink prefix. But the breadcrumbs have not ! see image
https://share.getcloudapp.com/7KuzrvvK
Try it with the AIOSEO plugin or any other SEO plugin with breadcrumbs and it just works fine. It picksup the correct permalink for the Portfolio Archive Page in the breadcrumbs path.
Got it? If not get back to me please. Of provide me your skype ID and we can make a appointment and talk in dutch and do screensharing so both issues i described are completely clear. Thank you !
note: I did not even talked about WPML and translatable slugs (permalinks) Then the yoast plugin completely fails on this. Because of the same problem.
Thanks for explaining the logic to me! I set the portfolio single page base to livingthings, saved changes and used the Yoast Test Helper plugin to reset the indexables table and migrations. The point of that is that previously optimized data becomes invalid or incomplete. A reset of the optimization is to ensure we’ve removed any invalid data. The result in my case is that the breadcrumb path remains the same, and portfolio now points to livingthings. Please try the following on your end too:
- Install & activate the Yoast Test Helper plugin
- Go to Tools > Yoast Test
- Locate the Yoast SEO section and click on the ‘Reset indexables tables & migrations‘, ‘Reset Prominent words calculation‘, and ‘Reset Internal link counter‘ buttons. After each click, the page will reload to confirm that the specific reset was successful.
- Go to SEO > Tools, and under SEO data, click the “Start SEO data optimization” button to allow Yoast to rescan your content.
Do let me know how it goes.
I know that a reset of the indexable tables will work.
I even have a better solution on saving the permalinks just drop the field in the table.
The moment i add this into the save of the permalinks it does it automatically and deletes the false permalink record in your table.
// fix for yoast breadcrumbs path to force use of the new portfolio permalink.
if (function_exists('yoast_breadcrumb') && !empty(yoast_breadcrumb('<section id="breadcrumbs">','</section>',false))) {
$table_db_name = $wpdb->prefix . "yoast_indexable";
if($wpdb->get_var("SHOW TABLES LIKE '$table_db_name'") == $table_db_name) {
$delete_result = $wpdb->get_results( $wpdb->prepare( "DELETE FROM ".$table_db_name. " WHERE object_type=%s and object_sub_type=%s",'post-type-archive', 'portfolio'));
}
}
But this should work out of the box without any extra plugins. The indexable tables should update once the permalinks are set or changes. Like they do in any other seo plugin with breadcrumbs.
Please drop this on your developers tables to have it fixed once and for all. This issue occurs in every theme that uses the yoast plugin with custom permalinks and has_archive=> true in the custom_post_type declaration.
Its a BUG not a FEATURE! 🙂
Adding WPML into the equasion makes it even more complicated. So every user we now have to explain that once using Yoast SEO and you change the permalinks you need a extra plugins and reset the indexable data in the tables? Sorry this makes me laugh. We live in the 21 century! This should be a automated process.
Note: I am respecting your suggestion and it works. But it is not the solution to the problem.
The point of that is that previously optimized data becomes invalid or incomplete. A reset of the optimization is to ensure we’ve removed any invalid data.
So the point is exactly: On save of the permalinks those tables should be flushed automatically.
Thanks for sharing the feedback and I’d pass this along.
Thank you for the feedback. Let me please know what their answer is.
Permalinks settings are dynamically in wordpress. WPSEO plugin make them static again by the way that plugins works and saves them only once in a table. After which each next adjustment in the permalink gets into oblivion.
That can not be the case. Yoast who is part of the wordpress development team should know and acknowledge this.
This is below his “STATUS” he has in developing a seo plugin. What came to my mind after discovering this….
Advice everybody not to use anymore the wpseo plugin, strip wpseo support from the theme as this is back in time.
Similar issue i read somebody reporting about breadcrumbs… You Turn them off and they still occur in the json data added to the page. He got a answer that one can add additional code in to the functions.php to completely strip them out! Why? He turned them off in the settings!!
That alone should be enough to get rid of all breadcrumbs data. Even in the json microdata. Apparently automation of steps can have some improvement at wpseo i guess. It does not make sense. Then why is that setting there in the first place? Anyway that is another discussion.
Thank you again and looking forward to your reply from the dev team.
Hi,
I’ve been looking at this, and I think that there might be an easy fix.
If I’m understanding the approach correctly, it looks like you’re just switching out the slug variable, but not triggering any of the actions you’d typically want WordPress to run in such a case (e.g., flushing rewrites via flush_rewrite_rules).
It’s worth noting that we do update our indexables table on update_option_permalink_structure (and update_option_category_base + update_option_tag_base) but these never fire in your setup.
Perhaps you could try running update_option_permalink_structure as part of your save process?
@jonoaldersonwp wordpress fires that action after the save of the permalinks. Look into the class-wp-rewrite.php. It is WPSeo who has todo its stuff.
The flush of permalinks is also done by wp after you (re)save the permalinks.
Other plugins all work fine when adjusting the permalinks and (re)save them. This issue belongs on the dev table of wpseo.
public function set_permalink_structure( $permalink_structure ) {
if ( $permalink_structure != $this->permalink_structure ) {
$old_permalink_structure = $this->permalink_structure;
update_option( 'permalink_structure', $permalink_structure );
$this->init();
/**
* Fires after the permalink structure is updated.
*
* @since 2.8.0
*
* @param string $old_permalink_structure The previous permalink structure.
* @param string $permalink_structure The new permalink structure.
*/
do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure );
}
}
You can see that function doesn’t run if the permalink structure hasn’t changed. In your code, you’re not changing the permalink structure, you’re switching out the values of the slugs.
@jonoaldersonwp so in order to be compatible with the wpseo plugin one has to fire 3 actions (one for the archive slug, one for the category slug and one for the tag slug). Is this something WPSeo came up with?
Where is this documented @wordpress.org documentation? I can’t find it at any documentation about permalinks or custom posttypes at wordpress.org
Why is this needed? There is no other plugin or addon that requires this. They just pick up the changed permalink without these actions even being fired.
If every plugin starts creating their own action names for this adding custom posttypes when permalinks change this can become a very long list of code to add.
Anyway it solves my issue with yoast seo plugin. Thanks for the hint.
Note: I tested this issue with 5 different themes using custom permalinks and the wpseo plugin and they all have the same issue!
So please tell me where at wordpress.org are these actions documented?
Not even the woocommerce from wordpress itself fires these actions after the permalinks for products or taxonomies are changed. You can not find any of these action being called in their code.
update_option_permalink_structure, update_option_category_base, update_option_tag_base
To me it looks like this is something WPSEO came up with. I still consider it a bug or bad coding.