Skip to main content
added 18 characters in body
Source Link
Tom J Nowell
  • 60.6k
  • 7
  • 77
  • 147

There has been a misunderstanding of how page content works here:

but this code not modified links in page content. What is wrong with this code?

The filter you used will adjust the links atOnce the moment they're generated, but those links are saved in the pagepost content you have already been generated in the past. Modifying the code won't trigger WordPress to open up every page, regeneratereopen the contents,post and publishresave/reinsert for new updatescode to take effect. If it did there would be catastrophic consequences on large sitesFilters only modify the links when they are created, as well as lots of unintended problemsthey can't change already saved post content.

What About Widgets/Blocks/Shortcodes?

Those places where code is being used to generate the links at runtime dynamicallyPlaces such as shortcodes or server rendered blocks will immediatelyimmediatley update as there is no saved data that needs to be recreatedthey create new fresh HTML when viewed, but anything that stored those values in postthe database/post meta/post content will need to be manually updated.

Is There a Different Filter For This?

No, that's not how this works, you would still need to open those pages in the admin to change the links.

So What Should I Do?

You have several options:

  • Find all the places that have your old custom HTML via search, edit and reinsert the links then save
  • when you reinsert the links consider using a block or shortcode instead so that you don't have to do this again in the future
  • if you are using a page builder you should ask in their communities as they can use different methods that require unique answers specific to that page builder

There has been a misunderstanding of how page content works here:

but this code not modified links in page content. What is wrong with this code?

The filter you used will adjust the links at the moment they're generated, but those links in the page content have already been generated in the past. Modifying the code won't trigger WordPress to open up every page, regenerate the contents, and publish new updates. If it did there would be catastrophic consequences on large sites, as well as lots of unintended problems.

Those places where code is being used to generate the links at runtime dynamically will immediately update as there is no saved data that needs to be recreated, but anything that stored those values in post meta/post content will need to be manually updated.

There has been a misunderstanding of how page content works here:

but this code not modified links in page content. What is wrong with this code?

Once the links are saved in the post content you have to reopen the post and resave/reinsert for new code to take effect. Filters only modify the links when they are created, they can't change already saved post content.

What About Widgets/Blocks/Shortcodes?

Places such as shortcodes or server rendered blocks will immediatley update as they create new fresh HTML when viewed, but anything that stored those values in the database/post meta/post content will need to be manually updated.

Is There a Different Filter For This?

No, that's not how this works, you would still need to open those pages in the admin to change the links.

So What Should I Do?

You have several options:

  • Find all the places that have your old custom HTML via search, edit and reinsert the links then save
  • when you reinsert the links consider using a block or shortcode instead so that you don't have to do this again in the future
  • if you are using a page builder you should ask in their communities as they can use different methods that require unique answers specific to that page builder
Source Link
Tom J Nowell
  • 60.6k
  • 7
  • 77
  • 147

There has been a misunderstanding of how page content works here:

but this code not modified links in page content. What is wrong with this code?

The filter you used will adjust the links at the moment they're generated, but those links in the page content have already been generated in the past. Modifying the code won't trigger WordPress to open up every page, regenerate the contents, and publish new updates. If it did there would be catastrophic consequences on large sites, as well as lots of unintended problems.

Those places where code is being used to generate the links at runtime dynamically will immediately update as there is no saved data that needs to be recreated, but anything that stored those values in post meta/post content will need to be manually updated.