Home › Forums › Backend Issues (wp-admin) › Distributing ACF in a free plugin › Reply To: Distributing ACF in a free plugin
Thanks for your reply but unfortunately not work
If I ‘die’ just befor thee function_exists()
, it dies… but I never go through :-/
<?php
if ( ! defined( 'ABSPATH' ) ){ exit; } // Exit if accessed directly
function wpcasama_create_acf_field() {
if ( function_exists( "acf_add_local_field_group" ) ) {
acf_add_local_field_group( array(
'id' => 'acf_mail-alert',
'title' => 'Mail Alert',
'fields' => array(
array(
'key' => 'field_5ac3bb4effff5',
'label' => 'Phone',
'name' => 'wpcasama_phone',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'none',
'maxlength' => '',
),
array(
'key' => 'field_5ac3bb9adb144',
'label' => 'city',
'name' => 'wpcasama_city',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array(
'key' => 'field_5ac3bbc9db145',
'label' => 'Minimum Price',
'name' => 'wpcasama_min_price',
'type' => 'number',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'min' => 0,
'max' => '',
'step' => 1,
),
array(
'key' => 'field_5ac3bbf8db146',
'label' => 'Maximum Price',
'name' => 'maximum_price',
'type' => 'number',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'min' => 0,
'max' => '',
'step' => 1,
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'wpcasa-mail-alerte',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array(
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array(),
),
'menu_order' => 0,
) );
}
}
add_action('init', 'wpcasama_create_acf_field', 200);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The most recent ACF Chat Friday featured a live demo of how to register CPTs directly in the plugin, one of our most requested features. Check out the summary below for a replay of the demo, and don’t forget to register for the next session! https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 9, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.