Skip to content

Instantly share code, notes, and snippets.

@joeyz
joeyz / tax-redirect
Created October 20, 2014 14:09
Genesis template page redirect for taxonomy
/**
* [WordPress] Template Redirect
* Use archive-books.php for Genre taxonomy archives.
*/
add_filter( 'template_include', 'sk_template_redirect' );
function sk_template_redirect( $template ) {
if ( is_tax( 'sports-book-cat' ) )
$template = get_query_template( 'archive-books' );
return $template;
@joeyz
joeyz / wpautop-cleanup
Created October 16, 2014 14:59
Cleanup WP formatting for shortcodes
if( !function_exists('wpex_fix_shortcodes') ) {
function wpex_fix_shortcodes($content){
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']'
);
$content = strtr($content, $array);
return $content;
}
@joeyz
joeyz / uber-triangles
Created October 14, 2014 16:56
Add little triangles to the submenus for Uber Menu
.ubermenu-main .ubermenu-item-level-0.ubermenu-has-submenu-drop.ubermenu-active > .ubermenu-target:before{
content: '';
display:block;
border:6px solid transparent;
border-bottom-color:#fff;
position:absolute;
bottom:0;
left:50%;
margin-left:-3px;
margin-bottom:-1px;
@joeyz
joeyz / gist:2f7964711786bee1ef09
Created October 13, 2014 19:14
WooCommerce Add header image with the categories thumnail
<div class="row">
<div class="archive-header">
<?php
//firs argument of the action is WHERE the function hooks into
add_action( 'woocommerce_before_main_content', 'woocommerce_category_image', 2 );
function woocommerce_category_image() {
if ( is_product_category() ){
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
@joeyz
joeyz / num-per-row
Created October 13, 2014 18:14
WooCommerce Override number of products per row
//Goes in functions.php
// Change number or products per row to 3
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
@joeyz
joeyz / sticky-footer
Created October 10, 2014 14:57
jQuery responsive sticky footer
@joeyz
joeyz / basic-widget
Created October 9, 2014 20:02
Basic Widget Code
<?php
/*
Plugin Name: Custom Mini Cart
Plugin URI: https://www.zendesignfitm.com/
Description: A widget framework for jewelry dropdown.
Version: 1.0
Author: Joey Z
Author URI: https://www.zendesignfirm.com/
License: GPL
*/
@joeyz
joeyz / wp-plugin-include
Created October 9, 2014 19:37
Proper way to include plugins in your WP theme
// This function loads the plugin.
function jz_load_plugin() {
if (!class_exists('Vintage_Engagement_Widget')) {
// load Vintage Engagement Widget if not already loaded
include_once(TEMPLATEPATH.'/plugins/vintage_engagement_widget.php');
}
if (!class_exists('Jewelry_Widget')) {
// load Vintage Engagement Widget if not already loaded
include_once(TEMPLATEPATH.'/plugins/jewelry_widget.php');
@joeyz
joeyz / cpt-search-results
Last active August 29, 2015 14:07
Search Results Page for a CPT
<?php
/*
Template Name: Events Search Page
*/
global $query_string;
$query_args = explode("&", $query_string);
//this is where you would normally put your $args array
$search_query = array();
@joeyz
joeyz / cpt-search
Created October 9, 2014 16:02
Search form for Custom Post Types