Skip to content

Instantly share code, notes, and snippets.

<?php
// check if the flexible content field has rows of data
if( have_rows('flexible_content_field_name') ):
// loop through the rows of data
while ( have_rows('flexible_content_field_name') ) : the_row();
if( get_row_layout() == 'paragraph' ):
<?php
$rows = get_field('repeater_field_name' ); // get all the rows
$rand_row = $rows[ array_rand( $rows ) ]; // get a random row
$rand_row_image = $rand_row['sub_field_name' ]; // get the sub field value
// Note
// $first_row_image = 123 (image ID)
$image = wp_get_attachment_image_src( $rand_row_image, 'full' );
<?php
$rows = get_field('repeater_field_name' ); // get all the rows
$first_row = $rows[0]; // get the first row
$first_row_image = $first_row['sub_field_name' ]; // get the sub field value
// Note
// $first_row_image = 123 (image ID)
$image = wp_get_attachment_image_src( $first_row_image, 'full' );
<?php if( have_rows('repeater_field_name') ): ?>
<ul class="slides">
<?php while( have_rows('repeater_field_name') ): the_row();
// vars
$image = get_sub_field('image');
$content = get_sub_field('content');
$link = get_sub_field('link');
<?php
// check if the repeater field has rows of data
if( have_rows('repeater_field_name') ):
// loop through the rows of data
while ( have_rows('repeater_field_name') ) : the_row();
// display a sub field value
the_sub_field('sub_field_name');
@tjhole
tjhole / functions.php
Created October 15, 2015 15:28
WORDPRESS: Function.php remove all featured images
global $wpdb;
$wpdb->query( "
DELETE FROM $wpdb->postmeta
WHERE meta_key = '_thumbnail_id'
" );
@tjhole
tjhole / iThemes: Disable SSL Check Security
Created October 13, 2015 08:19
iThemes: Disable SSL Check Security
define( 'ITSEC_TEST_MALWARE_SCAN_DISABLE_SSLVERIFY', true );
@tjhole
tjhole / jQuery: if touch
Created September 21, 2015 10:33
jQuery: if touch
function is_touch_device() {
try {
document.createEvent("TouchEvent");
return true;
} catch (e) {
return false;
}
}
@tjhole
tjhole / ACF : Lookup Radio Checkbox Field Labels
Created September 7, 2015 09:08
ACF : Lookup Radio Checkbox Field Labels
<?php
$field_key = get_field('key_field');
$field = get_field_object($field_key);
if( $field ):
echo '<ul id="filter" class="' . $field['key'] . '">';
foreach( $field['choices'] as $k => $v ) {
echo '<li class="filter" data-filter="'. $k .'">'. $v .'</li>';
}
echo '</ul>';
endif; ?>
@tjhole
tjhole / iThemes Exchange Postcode Zip
Created August 26, 2015 15:33
iThemes Postcode Zip State
/* ========================================================================================================================
iThemes Postcode
======================================================================================================================== */
function my_translated_text_strings( $translated_text, $untranslated_text, $domain ) {
$translated_text = $untranslated_text;