Skip to content

Instantly share code, notes, and snippets.

View jesgs's full-sized avatar
🍜
Ramen connoisseur

Jess Green jesgs

🍜
Ramen connoisseur
View GitHub Profile
<?php
add_filter('posts_request', function ($request, $query){
if( ($query->is_main_query() && $query->is_front_page()) && !$query->is_admin) {
return false;
} else {
return $request;
}
}, 10, 2);
<?php
/**
* Modify WP_Query to return taxonomy fields in post array
*
* @author Jess Green <jgreen AT psy-dreamer.com>
*/
add_filter('posts_orderby', 'taxonomy_orderby');
add_filter('posts_fields', 'taxonomy_archive_select_fields');
add_filter('posts_join', 'taxonomy_archive_join');
#!/bin/sh
# Run when Media audio option disappears from devices.
pacmd load-module module-bluetooth-discover
@jesgs
jesgs / wwsr.c
Created September 16, 2014 15:00
Wireless Weather Station Reader
/*
* wwsr - Wireless Weather Station Reader
* 2007 dec 19, Michael Pendec (michael.pendec@gmail.com)
* Version 0.5
* 2008 jan 24 Svend Skafte (svend@skafte.net)
* 2008 sep 28 Adam Pribyl (covex@lowlevel.cz)
* Modifications for different firmware version(?)
*/
#include <stdio.h>
#include <string.h>
@jesgs
jesgs / api-helpers.php
Last active August 29, 2015 14:13
Fix for post_parent field sorting problem in ACF5 Pro. Untested so use at your own risk!
<?php
// line 1689 advanced-custom-fields-pro/api/api-helpers.php
// Replace line 1689 with these two lines of code:
$page_parent_id = isset($args['post_parent']) ? $args['post_parent'] : 0;
$all_posts = get_page_children( $page_parent_id, $all_posts );
@jesgs
jesgs / bulk-edit-thoughts.md
Last active August 29, 2015 14:14
Adding to Bulk Edit Screen Findings

General Assumptions: Bulk Edit fields are submitted via Ajax

Findings: It is not — Quick Edit (aka Inline Edit) for individual posts is submitted via Ajax. No additional JS work needs to be done to submit Quick Edit field values.

However, when Quick Edit fields are updated, JS is needed to update the fields after updating the post because WordPress doesn't refresh the quick edit fields when the post has been updated.

Differences: Bulk Edit vs Quick Edit

Bulk Edit data is submitted via a GET request while Quick Edit data is submitted via a POST request.

The GET request for Bulk Edit data is generally arranged as:

@jesgs
jesgs / locate-template.php
Created February 6, 2015 20:37
WordPress locate_template example
<?php
/**
* Theme view template example using locate_template
*
* @return string
*/
function my_theme_template()
{
// do view related stuff
@jesgs
jesgs / 00-blinker-fadecandy-js-readme.md
Last active August 29, 2015 14:18
Node.js-version of Arduino code for Spooky LED Eyes (on Adafruit)
@jesgs
jesgs / 00-README.md
Last active August 29, 2015 14:18
Working with WordPress's Metadata API

Working with WordPress's Metadata API

This tutorial describes how to work with the WordPress Metadata API as described in the tutorial (Working with WordPress's Metadata API) posted on my blog.