Skip to content

Instantly share code, notes, and snippets.

@salaros
Last active November 3, 2018 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salaros/1fa92b3b65251c4f6f5787f0eca165ad to your computer and use it in GitHub Desktop.
Save salaros/1fa92b3b65251c4f6f5787f0eca165ad to your computer and use it in GitHub Desktop.
WordPress - ACF custom forms
<?php
require_once 'acf.php';
add_action('admin_head', function () {
do_action('acf/input/admin_head');
acf_form_head();
wp_enqueue_media();
});
add_action('admin_enqueue_scripts', function () {
wp_enqueue_script('acf-input');
});
\Timber::render( 'backend-form.twig', null );
<div class="wrap">
<form method="post" action="">
{{ fn( 'acf_form', {
'field_groups': [ 'acf_tracking_mapping' ],
'form': false,
'post_id': 'mypageid'
}) }}
{{ fn( 'submit_button' ) }}
</form>
</div>
<?php
register_field_group(array (
'id' => 'acf_tracking_mapping',
'title' => 'Tracking array mapping',
'fields' => array (
array (
// Put some fields here
),
),
'location' => array(), // Won't appear anyway
'options' => array (
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment