Skip to content

Instantly share code, notes, and snippets.

@shazdeh
Last active January 3, 2016 22:28
Show Gist options
  • Save shazdeh/8528197 to your computer and use it in GitHub Desktop.
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.
<?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