Skip to content

Instantly share code, notes, and snippets.

View johnkvang's full-sized avatar

John K Vang johnkvang

View GitHub Profile
@johnkvang
johnkvang / four-column-acf-list
Created August 19, 2016 15:24
Create a 4-Column list looping through an ACF Repeater Field
// This snippet will loop through my ACF Repeater Field and create a large list of websites (or whatever you want).
// Then it will create 4 individual lists from that large list of websites. Making it easier for me
// to style and/or create a 4-column list.
<?php
// Name of Repeater field
$names_array = get_field( 'field_name' );
// Counts Users
$name_count = count( $names_array );
@johnkvang
johnkvang / functions.php
Last active August 18, 2016 16:46
Drop Multiple Pin Colors on Google Maps and ACF
//Register for a Google Maps JS API key
//Make an ACF Field in options called 'api_key'.
if ( is_page_template( 'page-locations-single-map.php' ) ) { // Template Name
$api_key = get_option( 'options_api_key', '' );
$api_src = add_query_arg( 'key', $api_key, '//maps.googleapis.com/maps/api/js' );
wp_enqueue_script(
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
define('SAVEQUERIES', true);
@johnkvang
johnkvang / acf_repeater_subfields_with_alternating_classes.txt
Last active April 10, 2019 15:09
Give an ACF Repeater subfield alternating classes, in this case, 'Odds' and 'Evens'. This can be applied to other things as well. Be creative. :)
<?php if ( have_rows( 'acf_repeater_field' ) ) : ?>
<?php $counter = 1 ; ?>
<?php while ( have_rows( 'acf_repeater_field' ) ) : the_row(); ?>
<?php
if ( 0 === $counter % 2 ) {
$class = 'even';
} else {