Skip to content

Instantly share code, notes, and snippets.

@shazdeh
shazdeh / gist:8290250
Created January 6, 2014 21:39
Highlight current post in the loop
<?php
function highlight_current_post( $classes ) {
global $post, $wp_query;
if( $post->ID == $wp_query->post->ID ) {
$classes[] = 'current-post';
}
return $classes;
@shazdeh
shazdeh / gist:8242672
Last active January 2, 2016 03:19
Pinshop: enable the right sidebar on product category pages
<?php
function custom_product_category_layout( $class ) {
if( themify_is_function('is_product_category') ) {
$class = 'sidebar1';
}
return $class;
}
add_filter( 'themify_default_layout', 'custom_product_category_layout' );
@shazdeh
shazdeh / gist:8190595
Created December 31, 2013 00:41
Builder: break 4 column grids to 2 columns in tablets
@media (min-width: 480px) and (max-width: 959px) {
.col4-1 {
width: 46.8%;
}
.col4-1:nth-child(2n+1) {
margin-left: 0;
}
}
@shazdeh
shazdeh / gist:8188033
Created December 30, 2013 20:58
Change default parameters of the gallery shortcode, disable links by default
<?php
function gallery_shortcode_defaults( $out, $pairs, $atts ) {
$out['link'] = 'none';
return $out;
}
add_filter( 'shortcode_atts_gallery', 'gallery_shortcode_defaults', 10, 3 );
@shazdeh
shazdeh / gist:8151589
Created December 27, 2013 19:40
Parallax: hide the header on a specific page (http://themify.me/docs/post-page-id) but keep the menu
.page-id-69 #header hgroup {
display: none;
}
.page-id-69 #headerwrap {
height: 0;
}
.page-id-69 #nav-bar {
top: 0;
bottom: auto;
}
@shazdeh
shazdeh / gist:8063162
Created December 20, 2013 23:16
Custom size for images displayed in attachment pages
<?php
function custom_attachment_size( $content ) {
if( is_attachment() ) {
global $post;
$content = wp_get_attachment_image( $post->ID, 'large' );
}
return $content;
}
add_filter( 'the_content', 'custom_attachment_size' );
@shazdeh
shazdeh / gist:8060358
Created December 20, 2013 19:51
Builder: "clean" style for Menu module
.module-menu.clean ul.nav,
.module-menu.clean ul.nav li,
.module-menu.clean li a,
.module-menu.clean li:hover,
.module-menu.clean li:active {
background: none;
border: none;
box-shadow: none;
}
@shazdeh
shazdeh / gist:7965581
Created December 14, 2013 22:10
Builder: less gap between the columns
.col4-1, .col4-2, .col4-3, .col3-1, .col3-2, .col2-1 {
margin-left: 1.5%;
}
.col4-1 {
width: 23.8%;
}
.col3-1 {
width: 32.3%;
}
.col4-2, .col2-1 {
@shazdeh
shazdeh / gist:7949549
Created December 13, 2013 19:13
Respect sticky posts in category requests
<?php
function putStickyOnTop( $posts ) {
global $wp_query;
if( $wp_query->is_category() ){
$sticky_posts = get_option('sticky_posts');
$num_posts = count( $posts );
$sticky_offset = 0;
//loop over posts and relocate stickies to the front
@shazdeh
shazdeh / gist:7868242
Created December 9, 2013 06:35
WooCommerce: Show the saved percentage on the sale products in the the sale flash
<?php
function custom_product_sale_flash( $output, $post, $product ) {
$percent = ( ( $product->regular_price - $product->get_price() ) / $product->regular_price ) * 100;
return '<span class="onsale">' . __( 'Save:', 'themify' ) . round( $percent ) . '% </span>';
}
add_filter( 'woocommerce_sale_flash', 'custom_product_sale_flash', 11, 3 );