Skip to content

Instantly share code, notes, and snippets.

@joeyz
joeyz / wp_dynamic_sidebar.php
Created March 30, 2015 02:51
WP dynamic sidebar
//Goes in Functions.php
// Widgetized Sidebar
function lavish_widgets_init() {
register_sidebar( array(
'name' => 'left sidebar',
'id' => 'left_sidebar',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
@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%);
@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 / 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 / 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 / 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');