Last active
January 3, 2016 22:28
-
-
Save shazdeh/8528197 to your computer and use it in GitHub Desktop.
Flatshop: use the product image as the background image when no background image is specified.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function custom_product_default_bg_image() { | |
$bg_image = themify_get( 'background_image' ); | |
if( ! $bg_image ) { | |
global $post; | |
$thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id(),'shop_single', true ); | |
echo "<style> .post-{$post->ID} .product-bg { background-image: url('{$thumb_url[0]}'); } </style>"; | |
} | |
} | |
add_action( 'woocommerce_after_shop_loop_item', 'custom_product_default_bg_image' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment