• Resolved ticketa

    (@ticketa)


    Hi, I’m sorry but even after a long time of searching I didn’t get the answer to my question:

    How to add an ACF extended field programmatically within my plugin?

    I tried to add the button field the same way I’d add any other ACF field

    array (
        'key' => 'field_termination_button',
        'label' => __( 'Terminate contract', 'rentiq' ),
        'name' => 'termination_button',
        'type' => 'button',
        'button_type' => 'button',
        'prefix' => 'rentiq_',
    )

    but it doesn’t do anything.
    Am I missing something substantial here or this just isn’t how the extended fields work?

    Thanks! Martin

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback! The problem is that you’re using the wrong field type. The ACF Extended button field type slug is: acfe_button, not button.

    If you would like to retrieve the correct field settings & types, I would recommend to create a “Test Field Group”, add all the fields you need, configure them the way you want and export the Field Group in PHP using the “Custom Fields > Tools > Export Field Groups” tool.

    This way, you’ll get the perfect PHP code to register the fields locally in your plugin.

    Hope it helps!

    Have a nice day.

    Regards.

    Thread Starter ticketa

    (@ticketa)

    Oh oh! Ok, problem solved ??

    The

    Tools > Export Field Groups

    is a great function, which I wasn’t aware of, cause I’ve been doing everything from the code side without the UI since the beginning.

    Thanks so much!

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I’m glad to hear that you discovered this awesome tool of ACF!

    Good luck with your plugin!

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add ACF extended field programmatically’ is closed to new replies.