Created
February 20, 2013 17:11
-
-
Save andrewlaskey/4997169 to your computer and use it in GitHub Desktop.
Adding ACF Location Field Edit to Front-end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In my base scss file I copied and pasted the css from the location field plugin | |
.location_dl {margin-left:10px;} | |
.location_dl::after | |
{ | |
content:""; | |
display:table; | |
clear:both; | |
} | |
.location_dt-address, | |
.location_dt-coordinates | |
{ | |
float:left; | |
display:block; | |
width:24px; | |
height:24px; | |
font:0/0 a; | |
color:transparent; | |
background-color:white; | |
background-image:url('img/sprite.png'); | |
background-repeat:no-repeat; | |
border-radius:50%; | |
box-shadow:0 0 3px rgba(0, 0, 0, 0.3); | |
} | |
.location_dt-address {cursor:pointer;} | |
.location_dt-address {background-position:5px 5px;} | |
.location_dt-address:hover {background-position:5px -20px;} | |
.location_dt-coordinates {background-position:5px -45px;} | |
.location_dd | |
{ | |
height:20px; | |
padding-top:4px; | |
margin-left:30px; | |
} | |
.location_map | |
{ | |
position:relative; | |
z-index:0; | |
width:100%; | |
height:300px; | |
clear:both; | |
} | |
.location_map-container | |
{ | |
position:relative; | |
padding:5px; | |
margin-top:10px; | |
background-color:#fff; | |
box-shadow:0 1px 3px rgba(0,0,0,.2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Add Edit a Map | |
*/ | |
?> | |
<?php | |
if (isset($_GET['update_post_id'])) { | |
$updated_post_id = $_GET['update_post_id']; | |
} | |
?> | |
<?php acf_form_head(); ?> | |
<?php get_header(); ?> | |
<div id="content"> | |
<div id="inner-content" class="wrap clearfix"> | |
<div id="split-bg" class="background-split"></div> | |
<div id="main" class="eightcol first clearfix" role="main"> | |
<?php | |
$site_post_slug = basename( get_permalink($updated_post_id) ); | |
query_posts(array( 'post_type' =>'site_post', 'posts_per_page'=>1, 'name'=>$site_post_slug ) ); | |
if (have_posts()) : while (have_posts()) : the_post(); ?> | |
<h2 class="h2">Update the Map Location</h2> | |
<h3><?php the_title(); ?></h3> | |
<?php | |
$options = array( | |
'post_id' => $post->ID, // post id to get field groups from and save data to | |
'field_groups' => array('164'), // this will find the field groups for this post (post ID's of the acf post objects) | |
'form_attributes' => array( // attributes will be added to the form element | |
'class' => '' | |
), | |
'return' => get_permalink($post->ID) , // return url | |
'html_field_open' => '<div class="field">', // field wrapper open | |
'html_field_close' => '</div>', // field wrapper close | |
'html_before_fields' => '', // html inside form before fields | |
'html_after_fields' => '', // html inside form after fields | |
'submit_value' => 'Update', // value for submit field | |
'updated_message' => 'Post updated.', // default updated message. Can be false to show no message | |
); | |
?> | |
/ | |
<?php acf_form( $options ); //display the form ?> | |
<?php endwhile; ?> | |
<?php else : ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment