Home Forums General Issues Extend default ACF Link field


Extend default ACF Link field

  • Hello,

    I would like to extend default link field by adding one more text input like link text. Then be able to assign the value within insert/edit link window and use it like so: $link['sr_only'];

    I have been searching in the web for extending fields but I think that I am not going in the right direction. Is there any possibility to achieve this?

    Will appreciate any help from you.

  • ACF uses WPs built in link field that is used when editing content. To change the ACF field you would need to change WP component. I don’t think anyone has figured out how to do this.

  • This seems to be the answer across multiple topic in acf forums ;(

    Say we want to add an ID – its easy to attach a field
    into the link dialog box. But the data isn’t being saved
    with acf.


    <div className=”flex flex-row”>
    <label htmlFor=”wpse_link_class col-6″>
    <span>Button Type</span>
    <select name=”wpse-link-class” id=”wpse_link_class”>
    <option value=”normal”>normal</option>
    <option value=”btn btn-yellow”>Yellow button</option>
    <option value=”btn btn-yellow btn-lg”>Yellow button (big)</option>
    <option value=”btn btn-outline”>Outline button</option>
    <option value=”btn btn-outline btn-lg”>Outline button (big)</option>
    <label for=”sgx_custom_link_id”>
    <span>Link ID</span>
    <input type=”text” name=”sgx_custom_link_id” id=”sgx_custom_link_id” />

    wpLink.getAttrs = function() {
    return {
    class: $( ‘#wpse_link_class’ ).val(),
    href: $.trim( $( ‘#wp-link-url’ ).val() ),
    target: $( ‘#wp-link-target’ ).prop( ‘checked’ ) ? ‘_blank’ : ”,
    id: $( ‘#sgx_custom_link_id’ ).val() // this doesn’t work.

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

You must be logged in to reply to this topic.