Add actions, filters, hooks, and scripts
This commit is contained in:
16
filters.php
Normal file
16
filters.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
function sp_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
|
||||
if( empty ( $html ) && in_array( get_post_type( $post_id ), array( 'sp_team', 'sp_tournament', 'sp_venue' ) ) ) {
|
||||
$parents = get_post_ancestors( $post_id );
|
||||
foreach ( $parents as $parent ) {
|
||||
if( has_post_thumbnail( $parent ) ) {
|
||||
$html = get_the_post_thumbnail( $parent, $size, $attr );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
add_filter( 'post_thumbnail_html', 'sp_thumbnail_html', 10, 5 );
|
||||
?>
|
||||
Reference in New Issue
Block a user