Skip to content

Instantly share code, notes, and snippets.


Travis Hensgen traversal

  • Traversal
  • Melbourne, Australia
View GitHub Profile
View gist:218fd5c55bf38f91651f
global $wf;
// suppose you have a post of type "family", slug "smith-family", with field set "details", and field "education_levels"
$selections = $wf->family( "smith-family" )->details->education_levels->selections();
// $selections is now a value-label pair of the current selections.
View gist:f0db969a8732f5df9ad0
$args = array(
'meta_query' => array(
'key' => 'fields.type',
'value' => 'bnb',
'compare' => '=',
View gist:e57d96397172ca25c088
// Add this to functions.php
function mp_template_change() {
echo "<script>jQuery( function($) { $('#mp-attributes select[name=page_template]').change(); } );</script>";
add_filter("admin_head", "mp_template_change");
View gist:5c6af20903555a13c35c
<!DOCTYPE html>
// Requires gmaps.js from GitHub:
View gist:ed1eb9a033a51e44b35d
function my_update_media($object_id, $object_type) {
global $wf;
if ($object_type == "post") {
$post = $wf->post($object_id);
View gist:ba1244ef052ecc7aa05f
// place this inside functions.php
function my_function() {
global $wf;
// should be able to loop over post types, for example
foreach ( $wf->post_types as $pt ) {
View gist:6a13e7786d168d7588db
// -- in functions.php
// --- Suppose you want to dedupe by a "first_name" field in a "bio" set
class MY_Post extends MEOW_Post {
function bio_firstname() {
return $this->bio->first_name();
View gist:20cfb74a164a4a302646
<?php foreach ($wf->type("production")->by("production_deadline_fields.deadline_date", "DESC") as $production) : ?>
<h2>Production: <?= $production->title ?></h2>
Date: <?= $production->production_deadline_fields->deadline_date ?>
<?php endforeach; ?>
View gist:f32bf2abc414cad855a8
// Add this method to MPFT_CheckboxList
// this returns an associative array of the selections, with keys being the checkbox values, values being the labels.
function selections() {
if (!isset($this->_tv)) {
$options = $this->field()->info->type_options;
traversal / gist:6684b050d013b68e8c6c
Created Oct 8, 2014
Getting an array of field set names
View gist:6684b050d013b68e8c6c
// assuming you have a post type "logo", here is the code to get an array of set names for that type.
echo "<h2>Logo Field Sets</h2>";
global $meow_provider;