AdvancedCustomFields / AdvancedCustomFields/acf
Link field does not save `nofollow` and `sponsored` fields added by Rank Math SEO
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
I'm using Rank Math SEO and it's adding 2 checkboxes to the popup that shows link settings, which goes with the link field type. The checkboxes in question are:
- Add rel="nofollow" (CSS ID:
#wp-link-nofollow) - Add rel="sponsored" (CSS ID:
#wp-link-sponsored)
I found an old thread that ACF is not compatible with Rank Math SEO to do this. However, looking into the code, and I see that target property is managed via JS in assets/build/js/acf-input.min.js.
To Reproduce
Steps to reproduce the behavior:
- Install and enable Rank Math SEO plugin
- Add ACF link field to anywhere. For illustration purposes, the link field is called
my_link. I also attached the JSON sync file. - Navigate to any page and use the link field.
- In "Insert/edit link" popup, select or enter URL and Link Text and check all options: (1) Open link in a new tab, (2) Add rel="nofollow", and (3) Add re="sponsored"
- Click "Add Link" to save
- Save page
- Thru PHP, dump
my_linklikevar_dump( get_field('my_link') ), which will output something like:
array (size=3)
'title' => string 'Test' (length=4)
'url' => string 'https://localhost/test' (length=22)
'target' => string '_blank' (length=6)
PHP dump does not show values for the 2 attributes.
Expected behavior
PHP should return values saved for 2 attributes. If I do a dump, I should see something like:
array (size=5)
'title' => string 'Test' (length=4)
'url' => string 'https://localhost/test' (length=22)
'target' => string '_blank' (length=6)
'nofollow' => boolean true
'sponsored' => boolean true
Screenshots or Video
Code
Version Information:
- WordPress Version: 6.8.1
- PHP Version: 8.2
- ACF Version: ACF Pro 6.4.2
- Browser: Chrome
Additional context
None
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with Rank Math SEO enabled and an ACF link field, then inspect assets/build/js/acf-input.min.js and the link field handling described in the report. The fix is complete when the nofollow and sponsored checkbox values are saved and returned alongside title, url, and target in get_field('my_link').
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php
- Domain
- full-stack
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100