Last active
June 13, 2017 09:58
-
-
Save FellowshipAgency/406fceb465e3ac461ae4d5edd95d4a91 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Filters default image arguments for TSF. | |
* | |
* @param array $defaults The image defaults. | |
* @param array $args The image callback arguments. | |
*/ | |
add_filter( 'the_seo_framework_og_image_args', function( $defaults, $args = array() ) { | |
if ( function_exists( 'is_product_category' ) ) { | |
if ( is_product_category() ) { | |
global $wp_query; | |
$cat = $wp_query->get_queried_object(); | |
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); | |
$image = wp_get_attachment_url( $thumbnail_id ); | |
if ( $image ) { | |
$defaults['image'] = $image; | |
} | |
} | |
} | |
return $defaults; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment