Skip to content

Instantly share code, notes, and snippets.

@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;
}
@joeyz
joeyz / testimonials_cpt.php
Last active August 29, 2015 14:17
WP Testimonials CPT
<?php
// For use in functions.php
// Dont forget to re-save your permalinks so that it actually shows up.
if ( ! function_exists('custom_post_type_testimonials') ) {
// Register Custom Post Type
function custom_post_type_testimonials() {
$labels = array(
'name' => _x( 'Testimonial', 'Post Type General Name', 'twentyfifteen' ),
@joeyz
joeyz / valign.css
Created March 25, 2015 03:39
Vertically align elements with css onluy
.parent-element {
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.element {
position: relative;
top: 50%;
transform: translateY(-50%);