Title: get single.php image src
Last modified: August 30, 2016

---

# get single.php image src

 *  Resolved [Redocneves](https://wordpress.org/support/users/redocneves/)
 * (@redocneves)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/get-singlephp-image-src/)
 * How to get the category image src on single.php
 * My code don’t works:
 *     ```
       <?php $terms = apply_filters( 'taxonomy-images-get-terms', '' );
       if ( ! empty( $terms ) ) {
           foreach ( (array) $terms as $term ) {
               $image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '', array(
               'image_id'  => $term->image_id ) );
               print 'src:'.$image_url.'</li>';
           }
       } ?>
       ```
   
 * [https://wordpress.org/plugins/taxonomy-images/](https://wordpress.org/plugins/taxonomy-images/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Redocneves](https://wordpress.org/support/users/redocneves/)
 * (@redocneves)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/get-singlephp-image-src/#post-6770442)
 * Now Code Works like:
 * header.php:
 *     ```
       <?php if(is_single()): $mainheadbar_img = taxonomy_images_plugin_single_src() ?>
       <?php else: $mainheadbar_img = apply_filters( 'taxonomy-images-queried-term-image-url', '', array('image_size' => 'full') );endif; ?>
       ```
   
 * functions.php
 *     ```
       function taxonomy_images_plugin_single_src( $default, $args = array() ) {
       	$filter = 'taxonomy-images-list-the-terms';
       	if ( current_filter() !== $filter ) {
       		taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter );
       	}
   
       	$args['having_images'] = true;
   
       	if ( ! taxonomy_image_plugin_check_taxonomy( 'category', $filter ) ) {
       		return '';
       	}
   
       	$terms = apply_filters( 'taxonomy-images-get-the-terms', '', $args );
   
       	if ( empty( $terms ) ) {
       		return '';
       	}
   
       	$output = '';
       	foreach( $terms as $term ) {
       		if ( ! isset( $term->image_id ) ) {
       			continue;
       		}
       		$image_attributes = wp_get_attachment_image_src( $term->image_id, $args['image_size'] );
           $image_src = $image_attributes[0];
           break;
       	}
   
       	if ( ! empty( $image_src ) ) {
       		return $image_src;
       	}
       	return '';
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘get single.php image src’ is closed to new replies.

 * ![](https://ps.w.org/taxonomy-images/assets/icon-256x256.png?rev=1283547)
 * [Taxonomy Images](https://wordpress.org/plugins/taxonomy-images/)
 * [Support Threads](https://wordpress.org/support/plugin/taxonomy-images/)
 * [Active Topics](https://wordpress.org/support/plugin/taxonomy-images/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/taxonomy-images/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/taxonomy-images/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Redocneves](https://wordpress.org/support/users/redocneves/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/get-singlephp-image-src/#post-6770442)
 * Status: resolved