Skip to content

Instantly share code, notes, and snippets.

@polevaultweb
Created July 11, 2020 21:58
Show Gist options
  • Save polevaultweb/f8469a550f82a52156af5831b3eba5d0 to your computer and use it in GitHub Desktop.
Save polevaultweb/f8469a550f82a52156af5831b3eba5d0 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'igp_image_post_taxonomy_terms', function ( $terms, $image, $post_id, $taxonomy ) {
$tags = isset( $image->tags ) ? maybe_unserialize( $image->tags ) : array();
if ( empty( $tags ) ) {
return $terms;
}
$tag_cat_mapping = array(
'whizalternatives' => 'alternatives',
'whizlongboards' => 'longboards',
'whizmidlengths' => 'midlength',
'whizshortboards' => 'shortboards',
);
foreach ( $tag_cat_mapping as $tag => $cat ) {
if ( in_array( $tag, $tags ) ) {
$term = term_exists( $cat, $taxonomy );
if ( $term ) {
$terms[] = $term['term_id'];
}
}
}
return $terms;
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment