You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
how to capture/hide the "warning" generated by this plugin when taxonomy-images-get-the-terms is called on a taxonomy for which the taxonomy-images function is not activated? or add a test function to your code "taxonomy-images-is-active-for-taxonomy"? As it is a warning and not an error I cannot try/catch it.
I want to automate the display of images for all terms of all taxonomies that have an image associated. Unfortunately your plugin raise a warning for taxonomies for which taxonomy-images has not be activated.
For info / other users my code for displaying all terms images is below, terms with no images get displayed as text links (to be put in your template functions.php).
function custom_taxonomies_terms_links_images() {
$id = get_the_ID();
$post_type = get_post_type($id);
$taxonomies = get_object_taxonomies($post_type);
$out_images = $out_texts = array();
foreach ($taxonomies as $taxonomy) {
//if ($taxonomy == 'post_format') //internal WP3.1+ taxonomy, skip.
// continue;
//next filter shows notice on blog if images not activated for taxonomy
$terms = apply_filters( 'taxonomy-images-get-the-terms', '', array(
'taxonomy' => $taxonomy,
'post_id' => $id
) );
// if the above rises a warning, then images are not activated for this taxonomy, then populate terms with:
// $terms = get_the_terms( $id, $taxonomy );
if ( !empty( $terms ) ) {
foreach ( $terms as $term )
if (!empty($term->image_id)) {
$out_images[] = '<li class="taxonomy-image"><a href="' . esc_url( get_term_link( $term, $taxonomy ) ) . '" title="'.$term->name.' ('.$taxonomy.')">' . wp_get_attachment_image( $term->image_id, 'detail' ) . '</li>';
}
else
$out_texts[] = '<a href="' .get_term_link($term->slug, $taxonomy) .'">'.$term->name.'</a>';
}
}
if ($out_texts)
$out_images[] = '<li class="taxonomy-text">'.join( ', ', $out_texts).'</li>';
return '<ul class="taxonomy-images-the-terms">'.join( '', $out_images).'</ul>';
}
simply call it with <?php echo custom_taxonomies_terms_links_images(); ?> wherever the loop is displaying the categories of a post, for instance.
The text was updated successfully, but these errors were encountered:
how to capture/hide the "warning" generated by this plugin when
taxonomy-images-get-the-terms
is called on a taxonomy for which the taxonomy-images function is not activated? or add a test function to your code "taxonomy-images-is-active-for-taxonomy"? As it is a warning and not an error I cannot try/catch it.I want to automate the display of images for all terms of all taxonomies that have an image associated. Unfortunately your plugin raise a warning for taxonomies for which taxonomy-images has not be activated.
For info / other users my code for displaying all terms images is below, terms with no images get displayed as text links (to be put in your template
functions.php
).function custom_taxonomies_terms_links_images() {
}
simply call it with
<?php echo custom_taxonomies_terms_links_images(); ?>
wherever the loop is displaying the categories of a post, for instance.The text was updated successfully, but these errors were encountered: