Support

Account

Home Forums General Issues Remove trailing slash from ACF URL-based fields

Solving

Remove trailing slash from ACF URL-based fields

  • I am currently in the final throes of building a site which uses lots (and lots!) of ACF Link fields, and the site is almost completely populated.

    I am now in a position where I need to remove the trailing slash from all URLs across the site, and can do this for system links just by updating Permalinks in WordPress Admin and using WP-CLI for WYSIWYG and basic text fields across the site.

    Unfortunately, however, this approach doesn’t seem to work for any ACF Link fields, where the data is stored in serialised JSON in the database, as WP-CLI doesn’t ‘catch’ these URLs and they obviously aren’t updated automatically when Permalinks are changed globally, as they’ve already been stored in the database with trailing slashes.

    Is there a quick way – ideally via SQL or in ACF itself – to remove the trailing slashes from all URLs created using Link fields, rather than repopulating hundreds of pages to not use the trailing slash versions of each link?

    Thanks in advance!

  • Further clarification – I should also note that the Link fields are all within different layouts within a Flexible Component field type.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.