Skip to content

Instantly share code, notes, and snippets.

@fabiofl
fabiofl / gist:5873100
Created June 27, 2013 00:41
Clear Mac OS X's icon cache.
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
@gregrickaby
gregrickaby / wordpress-transient-caching.php
Last active January 2, 2019 10:45
WordPress Transient Caching
<?php
/**
* Setup wp_query arguments for the loop. Cache the results for 4 hours.
*
* @link http://codex.wordpress.org/Transients_API
*/
// Check for transient
if ( false === ( $my_query = get_transient( 'foo_featured_posts' ) ) ) {
@v9n
v9n / Get object taxonomy of a custom post type.php
Created May 9, 2013 18:12
It's easy to get a list of taxonomy. wp_get_post_terms, get_term_list,..do the job. However, in the case you don't know the taxonomy name, then here is the code to find out it. This is take from WordPress core file. Meaning the function we need is: get_object_taxonomies
<?php
function get_post_taxonomies($post) {
// Passing an object
// Why another var?? $output = 'objects'; // name / objects
$taxonomies = get_object_taxonomies($post, 'objects');
/*// Passing a string using get_post_type: return (string) post, page, custom...
$post_type = get_post_type($post);
$taxonomies = get_object_taxonomies($post_type, 'objects');*/
/* normal flexbox */
.flexbox .flex-container {
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: flex;
}
.flexbox .flex-container.vertical {
display: -webkit-flex;
display: -moz-flex;
@thefuxia
thefuxia / t5-strip-double-spaces.php
Created December 6, 2012 21:14
T5 Strip double spaces in posts
<?php
/**
* Plugin Name: T5 Strip double spaces in posts
* Description: Replaces [space + no-break-space] with a regular space.
* Plugin URI: http://wordpress.stackexchange.com/questions/75197/remove-double-space-after-a-period
* Version: 2012.12.06
* Author: Thomas Scholz
* Author URI: http://toscho.de
* Licence: MIT
* License URI: http://opensource.org/licenses/MIT
@jameskoster
jameskoster / functions.php
Last active August 31, 2021 14:18 — forked from mikejolley/functions.php
WooCommerce - Exclude products from a particular category on the shop page
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() && is_shop() ) {
$q->set( 'tax_query', array(array(
@ramseyp
ramseyp / hide-editor.php
Created November 12, 2012 15:48
Hide the content editor for certain pages in WordPress
<?php
/**
* Hide editor on specific pages.
*
*/
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
// Get the Post ID.
@codearachnid
codearachnid / tribe_p2p_compat_fix.php
Created October 2, 2012 02:34
Fix compatibility issues with The Event Calendar and Posts 2 Posts WordPress Plugins
<?php
/**
* Fix compatibility issues with The Event Calendar and Posts 2 Posts WordPress Plugins
* Issue arrises with how nested select queries function when P2P expects a single column.
*/
function tribe_to_p2p_pre_get_posts_20121001( $query ){
if(isset($query->_p2p_capture) && $query->_p2p_capture) {
add_filter( 'posts_fields', 'tribe_to_p2p_setupFields_20121001', 20);
@paulruescher
paulruescher / Extend Recent Posts
Created June 26, 2012 19:02
Used this to change the output of WordPress' Recent Posts Widget
/**
* Extend Recent Posts Widget
*
* Adds different formatting to the default WordPress Recent Posts Widget
*/
Class My_Recent_Posts_Widget extends WP_Widget_Recent_Posts {
function widget($args, $instance) {
@helgatheviking
helgatheviking / custom-post-type-archive-menu-links.php
Created May 4, 2012 17:41
Adds Custom Post Type archives to the WordPress-powered menus
<?php
/*
Plugin Name: Custom Post Type Archive Menu Links
Plugin URI: http://codeseekah.com/2012/03/01/custom-post-type-archives-in-wordpress-menus-2/
Description: Easily Add Custom Post Type Archives to the Nav Menus
Version: 1.0
Author: soulseekah
Author URI: http://codeseekah.com
License: GPL2