Skip to content

Instantly share code, notes, and snippets.

View dalemoore's full-sized avatar

Dale Moore dalemoore

View GitHub Profile
<?php
/*
Description: Adds a taxonomy filter in the admin list page for a custom post type.
Written for: http://wordpress.stackexchange.com/posts/582/
By: Mike Schinkel - http://mikeschinkel.com/custom-workpress-plugins
Instructions: Put this code in your theme's functions.php file or inside your own plugin. Edit to suite your post types and taxonomies. Hope this helps...
*/
add_filter('manage_listing_posts_columns', 'add_businesses_column_to_listing_list');
function add_businesses_column_to_listing_list( $posts_columns ) {
if (!isset($posts_columns['author'])) {
@bueltge
bueltge / gist:1016587
Created June 9, 2011 11:58
Include custom taxonomy term in WordPress search
via http://wordpress.stackexchange.com/questions/2623/include-custom-taxonomy-term-in-search/5404#5404
function atom_search_where($where){
global $wpdb;
if ( is_search() )
$where .= "OR (t.name LIKE '%".get_search_query() . "%' AND {$wpdb->posts} . post_status = 'publish')";
return $where;
}
@jacine
jacine / template.php
Created November 19, 2011 01:02
Bye, bye region.tpl.php and block--system--main.tpl.php
<?php
/**
* Implements hook_page_alter().
*/
function mytheme_page_alter(&$page) {
// Remove all the region wrappers.
foreach (element_children($page) as $key => $region) {
if (!empty($page[$region]['#theme_wrappers'])) {
$page[$region]['#theme_wrappers'] = array_diff($page[$region]['#theme_wrappers'], array('region'));
@mikejolley
mikejolley / gist:1604009
Created January 13, 2012 00:31
WooCommerce - Add a special field to the checkout, order emails and user/order meta
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
/**
@joshuapowell
joshuapowell / preprocess.inc
Created January 26, 2012 02:13
Drupal: Remove as much pre-generated core CSS as possible
<?php
/**
* Implementation of hook_css_alter().
*/
function MYTHEME_css_alter(&$css) {
// Remove core block stylesheet(s)
unset($css[drupal_get_path('module', 'block') . '/block.css']);
@luetkemj
luetkemj / wp-query-ref.php
Last active May 25, 2024 10:56
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@antoniofrignani
antoniofrignani / gist:2867425
Created June 4, 2012 09:31
[WP] - Add featured thumbnail to admin post / page columns
// http://wpsnipp.com/index.php/functions-php/updated-add-featured-thumbnail-to-admin-post-page-columns/
if (function_exists( 'add_theme_support' )){
add_filter('manage_posts_columns', 'posts_columns', 5);
add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
add_filter('manage_pages_columns', 'posts_columns', 5);
add_action('manage_pages_custom_column', 'posts_custom_columns', 5, 2);
}
function posts_columns($defaults){
$defaults['wps_post_thumbs'] = __('Thumbs');
@steffenr
steffenr / .htaccess
Created June 15, 2012 10:05
Drupal htaccess optimizations
# KILL THEM ETAGS
# http://www.askapache.com/htaccess/apache-speed-etags.html
FileETag none
# set expires header
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf|woff|eot|svg|ttf)$">
Header set Expires "Tue, 16 Jun 2020 20:00:00 GMT"
</FilesMatch>
# turn on gzip compression
@gagarine
gagarine / template.tpl.php
Created July 29, 2012 21:11
Working with drupal theme_menu_tree
<?php
/**
* Theme_menu_tree doesn't provide any context information
* THIS SUCKS
* But you can use hook_block_view_alter to change the theme wrapper
* OUF!
*/
function MYTHEME_menu_tree(&$variables) {
@hissy
hissy / gist:3613306
Last active June 26, 2023 22:56
[WordPress] change next / previous post link ordering
<?php
/**
* Customize Adjacent Post Link Order
*/
function my_custom_adjacent_post_where($sql) {
if ( !is_main_query() || !is_singular() )
return $sql;
$the_post = get_post( get_the_ID() );
$patterns = array();