Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / remove_add_to_cart
Created October 24, 2014 18:17
Remove add to cart button on cat archive pages
//remove add to cart button on category archive pages.
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action('init','remove_loop_button');
@joeyz
joeyz / cpt_datepicker_hide
Last active August 29, 2015 14:08
Hide passed custom posts by datepicker value
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// WP_Query arguments
$args = array (
'post_type' => 'events',
'pagination' => true,
'paged' => $paged,
'meta_query' => array(
array(
'key' => 'event_date',
'value' => date('Ymd', strtotime('now')),
@joeyz
joeyz / fetchAPI.php
Created March 21, 2015 18:35
json to php object
<?php
function fetchData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}