Skip to content

Instantly share code, notes, and snippets.

@nanoanno
nanoanno / get_acf_image_with_alt-example.html
Created Mar 29, 2021
An example of using the get_acf_image_with_alt function
View get_acf_image_with_alt-example.html
<a class="member" href="<?php the_permalink(); ?>">
<?php echo get_acf_image_with_alt( 'serious_photo', get_the_ID(), 'team-member', false, 'serious-photo' ); ?>
<?php echo get_acf_image_with_alt( 'funny_photo', get_the_ID(), 'team-member', false, 'funny-photo' ); ?>
<p class="name"><?php the_title(); ?></p>
<p class="title"><?php the_field( 'team_page_title' ); ?></p>
</a>
@nanoanno
nanoanno / get_acf_image_with_alt
Last active Mar 26, 2021
Get ACF image with alt text (and add classes)
View get_acf_image_with_alt
// Load in ACF image with alt text
function get_acf_image_with_alt( $imagefield, $postID, $imagesize = 'full', $subfield = false, $class = '' ) {
if ( $subfield == true ) {
$imageID = get_sub_field( $imagefield, $postID );
}
else {
$imageID = get_field( $imagefield, $postID );
}
$image = wp_get_attachment_image_src( $imageID, $imagesize );
$alt_text = get_post_meta( $imageID , '_wp_attachment_image_alt', true );
@nanoanno
nanoanno / twenty-nineteen-custom-color-override
Last active Apr 17, 2019
Twenty-Nineteen Custom Color Override
View twenty-nineteen-custom-color-override
/*
* Set background for:
* - featured image :before
* - featured image :before
* - post thumbmail :before
* - post thumbmail :before
* - Submenu
* - Sticky Post
* - buttons
* - WP Block Button
@nanoanno
nanoanno / gist:9733309fe61ce1ce1f1c38a2a09104d4
Last active Aug 29, 2017
Book By Owner - Locations - Testimonial
View gist:9733309fe61ce1ce1f1c38a2a09104d4
<?php
if( have_rows('loc_testimonials') ) :
?>
<h2>Testimonials</h2>
<div class="bbo-columns">
<?php
while( have_rows('loc_testimonials') ) : the_row();
echo '<div class="bbo-column">';