Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#969 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript, php
领域
full-stack

调研方向

启用 Rank Math SEO 并使用 ACF 链接字段重现该问题,然后检查 assets/build/js/acf-input.min.js 以及报告中所述的链接字段处理。只有当 nofollow 和 sponsored 复选框的值与 title、url 和 target 一起在 get_field('my_link') 中保存并返回时,修复才算完成。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
PHP
星标
948
派生
198
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AdvancedCustomFields/acf 的其他 Issue

查看 AdvancedCustomFields/acf 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。