Skip to content

Instantly share code, notes, and snippets.

Avatar
🍜
Ramen connoisseur

Jess Green jesgs

🍜
Ramen connoisseur
View GitHub Profile
View main-query-disable.php
<?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);
@jesgs
jesgs / composer.json
Created Mar 3, 2014
Example composer.json file for add WordPress as a dependency to a project.
View composer.json
{
"repositories": [
{
"type": "package",
"package": {
"name": "wordpress",
"type": "webroot",
"version": "3.8.1",
"dist": {
"type": "zip",
View wordpress-gallery.php
View modify-wp-query.php
<?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');
View create-desktop-item.sh
#!/bin/sh
gnome-desktop-item-edit ~/Desktop --create-new
View start-bluetooth-media.sh
#!/bin/sh
# Run when Media audio option disappears from devices.
pacmd load-module module-bluetooth-discover
@jesgs
jesgs / wwsr.c
Created Sep 16, 2014
Wireless Weather Station Reader
View wwsr.c
/*
* 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 Aug 29, 2015
Fix for post_parent field sorting problem in ACF5 Pro. Untested so use at your own risk!
View api-helpers.php
<?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 Aug 29, 2015
Adding to Bulk Edit Screen Findings
View bulk-edit-thoughts.md

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 Feb 6, 2015
WordPress locate_template example
View locate-template.php
<?php
/**
* Theme view template example using locate_template
*
* @return string
*/
function my_theme_template()
{
// do view related stuff
You can’t perform that action at this time.