AdvancedCustomFields / AdvancedCustomFields/acf

Link field does not save `nofollow` and `sponsored` fields added by Rank Math SEO

Open
#969 1 comment 0 reactions 0 assignees View on GitHub

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:

  1. Add rel="nofollow" (CSS ID: #wp-link-nofollow)
  2. 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:

  1. Install and enable Rank Math SEO plugin
  2. Add ACF link field to anywhere. For illustration purposes, the link field is called my_link. I also attached the JSON sync file.
  3. Navigate to any page and use the link field.
  4. 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"
  5. Click "Add Link" to save
  6. Save page
  7. Thru PHP, dump my_link like var_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

Image

Code

group_6887e2457ce6b.json

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.