Skip to content

Instantly share code, notes, and snippets.

@krasenslavov
Last active April 26, 2020 15:41
Show Gist options
  • Save krasenslavov/81dc4aa5efd6ff9621154551923247ea to your computer and use it in GitHub Desktop.
Save krasenslavov/81dc4aa5efd6ff9621154551923247ea to your computer and use it in GitHub Desktop.
CPT UI + Advanced Custom Fields + Front-end data collection form. Visit blog post https://bit.ly/2KwpDWK
<?php
/**
* Template Name: Add Restaurant
* Template Post Type: page
*
* @package WordPress
* @subpackage Twenty_Twenty
* @since Twenty Twenty 1.0
*/
acf_form_head();
get_header();
?>
<main id="site-content" role="main">
<div class="page type-page status-publish hentry">
<div class="post-inner thin">
<div class="entry-content">
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
acf_form(array(
'id' => 4,
'post_id' => 'new_post',
'new_post' => array(
'post_type' => 'restaurants',
'post_status' => 'draft',
),
'uploader' => 'basic',
'submit_value' => 'Submit Your Restaurant &rarr;',
));
}
}
?>
</div>
</div>
</div>
</main>
<?php
acf_enqueue_uploader();
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment