Last active
October 3, 2015 02:18
-
-
Save PurpleHippoDesign/6e039e54d4869da94ce5 to your computer and use it in GitHub Desktop.
Removing ACF front end dependency
This file contains hidden or 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 | |
$gallery = get_post_meta( get_the_ID(), 'home_slider'); // 'home_slider' is name of my ACF gallery field | |
$image_ids = $gallery[0]; // It's an array within an array | |
// If we have some images loop around and populate a new data array | |
if( is_array( $image_ids )) { | |
$image_ids_string = implode( ',', $image_ids ); // Soliloquy Dynamic requires image IDs to be passed as a comma separated list | |
echo '<div class="gallery-slider">'; | |
soliloquy_dynamic( array( | |
'id' => 'gallery-images', | |
'images' => $image_ids_string, | |
'animate' => 'true' | |
) ); | |
echo '</div>'; | |
} |
This file contains hidden or 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 | |
$gallery = get_post_meta( get_the_ID(), 'gallery' ); // 'gallery' is name of my ACF gallery field | |
if( is_array( $gallery[0] )) { | |
$image_ids = $gallery[0]; | |
$shortcode = '[gallery columns="3" link="none" size="large" ids="' . implode(',', $image_ids) . '"]'; // build your gallery shortcode | |
echo do_shortcode( $shortcode ); | |
} |
This file contains hidden or 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 | |
$bg_image = get_post_meta( get_the_ID(), 'hero', true );// 'hero' is name of my ACF gallery field | |
$image_url = wp_get_attachment_url( $bg_image ); //get the image url | |
if ( $bg_image ) { | |
echo '<section class="hero-section" style="background-image:url('.$image_url.'); background-repeat:no-repeat;"> | |
</div">'; | |
} |
This file contains hidden or 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 | |
$url = esc_url( get_post_meta( get_the_ID(), 'my_url', true )); //'my_url' is name of my ACF url field | |
if ($url) { | |
echo '<a href="'.$url. '" class="button">Visit Link</a>'; | |
} |
This file contains hidden or 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 | |
$mycontent = wpautop (get_post_meta( get_the_ID(), 'test_wysiwyg', true )); // 'test_wysiwyg' is name of my ACF wysiwyg field | |
if ($mycontent) { | |
echo '<div class="row">' . $mycontent . '</div>'; | |
} |
This file contains hidden or 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 | |
$location = wpautop (get_post_meta( get_the_ID(),'location', true)); | |
$location = apply_filters('the_content', $location); //Apply filter to initiate shortcodes | |
if ( $location ) { | |
echo '<div class="location-map">' . $location. '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment