Skip to content

Instantly share code, notes, and snippets.

View mwangepatrick's full-sized avatar

Patrick N. Mwange mwangepatrick

View GitHub Profile
@mwangepatrick
mwangepatrick / sort_repeater
Last active August 21, 2016 11:27
This is a sample code on how to sort repeater fields
<head>
<?php
wp_head();
?>
</head>
<body>
<?php
<?php if ( function_exists( 'have_rows' ) && have_rows( 'page_section' ) ) : ?>
<?php while ( have_rows( 'page_section' ) ) : the_row(); ?>
<?php get_template_part( 'content', 'page-section' ); ?>
<?php endwhile; ?>
<?php if (is_front_page() && count( get_field( 'page_section' ) ) > 1) : ?>
function my_acf_get_fields_in_group( $group_id ) {
$acf_meta = get_post_custom( $group_id );
$acf_fields = array();
foreach ( $acf_meta as $key => $val ) {
if ( preg_match( "/^field_/", $key ) ) {
$acf_fields[$key] = $val;
}
}
<section class="member-list">
<?php if( have_rows('repeater_field') ): ?>
<?php while ( have_rows('repeater_field') ) : the_row(); ?>
<?php $user = get_sub_field('user_field'); ?>
<?php $userID = array_values($user)[0]; ?>
<?php $first_name = get_user_meta($userID, 'first_name', true); ?>
@mwangepatrick
mwangepatrick / sub_field_filter_repeater.php
Last active December 12, 2015 14:36
Filter repeater using more than one sub fields
<?php
/**
* Template Name: Events
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
@mwangepatrick
mwangepatrick / functions.php
Created April 2, 2016 11:21
Setting the height of wysiwyg
add_action('acf/input/admin_head', 'lh_acf_admin_head');
function lh_acf_admin_head() {
?>
<style type="text/css">
.acf-editor-wrap iframe {
height: 150px !important;
min-height: 150px;
}
.acf-editor-wrap .mce-fullscreen iframe{
<?php
add_action('acf/input/admin_head', 'my_acf_admin_head');
function my_acf_admin_head() {
?>
<script type="text/javascript">
(function($) {
@mwangepatrick
mwangepatrick / flex_clone.php
Created August 21, 2016 10:58
Cloning a flexible field with cloned fields inside
<!-- testing flexible clone field -->
<?php
// check if exists
if( have_rows('flexi_layouts_layout_elements') ):
/* load the cloned field group*/
$flexcontent = get_field('flexi_layouts_layout_elements');
//dump the data to verify the correct layout is returned
//var_dump($flexcontent);
// loop through the rows of data