Created
October 26, 2017 13:42
-
-
Save unwiredtech/a0aa4a0d540bb23354d89a91f7e826b5 to your computer and use it in GitHub Desktop.
ACF
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 | |
if ( ( is_user_logged_in() && $current_user->ID == $post->post_author ) ) { // Execute code if user is logged in or user is the author | |
acf_form_head(); | |
wp_deregister_style( 'wp-admin' ); | |
} | |
get_header(); | |
?> | |
<div id="main-content"> | |
<div class="container"> | |
<div id="content-area" class="clearfix"> | |
<div id="left-area"> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<div class="et_main_title"> | |
<h1 class="entry-title"><?php the_title(); ?></h1> | |
</div> | |
<div class="entry-content"> | |
<?php | |
the_content(); | |
?> | |
<div class="acf-directory-contact"> | |
<? $directory_telephone = get_field( "directory_telephone" ); | |
$directory_email = get_field("directory_email_address"); | |
$directory_fb = get_field("directory_facebook"); | |
$directory_in = get_field("instagram");?> | |
<h3>Contact</h3> | |
<p>Telephone: <?php echo $directory_telephone; ?><br/> | |
Email: <a href="mailto:<?php echo $directory_email; ?> "><?php echo $directory_email; ?></p> | |
<div class="social-icons directory-icons"> | |
<a class="dir-social-icons" href="<?php echo $directory_fb; ?>" target="_blank"><i class="fa fa-facebook fa-2x"></i></a> | |
<a class="dir-social-icons" href="<?php echo $directory_in; ?>" target="_blank"><i class="fa fa-instagram fa-2x"></i></a> | |
</div> | |
<div class="back-to-directory"> | |
<p><a href="/directory">« Back to Directory</a></p> | |
</div> | |
</div><!-- acf-directory-contact --> | |
</div> <!-- .entry-content --> | |
</article> <!-- .et_pb_post --> | |
<?php endwhile; ?> | |
<!-- Edit --> | |
<div class="acf-edit"> | |
<?php | |
/* Show the edit button to the post author only */ | |
if ( ( is_user_logged_in() && $current_user = wp_get_current_user() ) ) { ?> | |
<a class='post-edit-button' href="<?php echo get_permalink() ?>?action=edit">Edit Post</a> | |
<?php } ?> | |
<?php | |
if (isset($_GET['action'])) { | |
if($_GET['action'] == 'edit') { ?> | |
<div class="acf-edit-post"> | |
<!-- Put the edit form code from the next step here --> | |
<?php | |
if ( ( is_user_logged_in() && $current_user->ID == $post->post_author ) ) { | |
echo "<div class='acf-edit-post'>"; | |
acf_form (array( | |
'form' => true, | |
'return' => '%post_url%', | |
'submit_value' => 'Save Changes', | |
'post_title' => true, | |
'post_content' => true, | |
'field_groups' => 236, // Same ID(s) used before | |
)); | |
echo "</div>"; | |
} | |
?> | |
</div> | |
<?php } | |
} | |
?> | |
</div><!-- acf-edit --> | |
</div> <!-- #left-area --> | |
<?php get_sidebar(); ?> | |
</div> <!-- #content-area --> | |
</div> <!-- .container --> | |
</div> <!-- #main-content --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment