Home Forums ACF PRO Extend ACF Link Element data with RankMath Link options


Extend ACF Link Element data with RankMath Link options

  • Hi there,

    We are using a couple of ACF blocks within Gutenberg to extend our content.
    For example, there are some buttons that were generated by a link element.

    We are also using RankMath for SEO. RankMath extends the normal WP link dialog with a few extra options.
    For example, we have two more options below the “open in a new tab” checkbox, in this case it’s for rel=“nofollow / sponsored”.
    I mean this dialog:

    The additional checkboxes are also appeared within the Link dialog of ACF, but there were not saved anywhere.

    But we also need this options within the block to generate the link accordingly to these settings.

    Is it possible via Filter or Hook to also save these additional checkboxes from RankMath within the ACF link element and use them in the output?

    If not, is there any other good way to add those settings?

    Thanks for your help and ideas!

    Kind regards,

  • When you use an ACF link field do those extra setting appear in the link popup?

  • @hube2 yes, the screen capture is from an ACF link field popup.

  • Thanks, that confirms that ACF uses the standard WP popup.

    I cannot give you specifics, but it might be possible. When you save the value in the popup ACF saves each of the settings to a hidden field.

    You could use the acf/render_field action to create additional hidden fields following the same pattern as the current hidden fields.

    Then you could potentially detect that window closing or there might be an action in the ACF JS API that you can hook into that to get the values from the new settings and save them to your new hidden fields.

    I’m 99% sure that ACF will save these values as part of the array that it normally saves for a link field if they exist. But you might need to add an acf/update_field filter to add the values to the array.

    Then you can add an acf/format_value filter to return a link with these values added to it.

  • Thank you, I will check those filters and hooks.

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

You must be logged in to reply to this topic.