Title: term variable not working in shortcode
Last modified: August 30, 2016

---

# term variable not working in shortcode

 *  Resolved [eSaner](https://wordpress.org/support/users/esaner/)
 * (@esaner)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/term-variable-not-working-in-shortcode/)
 * I’m having trouble getting the new term variable to work in a shortcode.
 * I have a custom taxonomy with the slug “types”, for which show_ui is set to true.
   The types taxonomy is connected to a custom post type with the slug “building”.
   The types taxonomy has four terms with the slugs “residential”, “commercial”,“
   agricultural”, and “equine”.
 * The following [tax_img] shortcode works with attributes of “size” and “format”,
   but “term” does not work. The shortcode will display an image on a taxonomy archive
   page, but it only shows the featured image for the term displayed on that archive
   page. So when the shortcode is used on [http://example.com/types/residential](http://example.com/types/residential)
   only the featured image for the term “residential” is displayed, even if the 
   shortcode attribute “term” is set to term=”commercial”.
 *     ```
       add_shortcode('tax_img', 'es_taxonomy_image');
       function es_taxonomy_image( $atts ) {
       	$a = shortcode_atts( array( 'format' => 'html', 'size' => 'thumbnail', 'term' => '16' ), $atts );
       	$image = gtaxi_get_taxonomy_image( array( 'format' => $a['format'], 'size' => $a['size'], 'term' => $a['term'] ) );
   
       	return $image;
       }
       ```
   
 * One perhaps related issue: the following code displays nothing on types taxonomy
   archive pages, even though each types term has a featured image.
 *     ```
       add_action('genesis_before_loop', 'es_tax_img');
       function es_tax_img() {
       		$image = gtaxi_get_taxonomy_image();
       		return $image;
       }
       ```
   
 * WordPress 4.3
    Genesis 2.2 Genesis Taxonomy Images 1.0 Genesis Sample Child Theme
 * [https://wordpress.org/plugins/genesis-taxonomy-images/](https://wordpress.org/plugins/genesis-taxonomy-images/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [theMikeD](https://wordpress.org/support/users/themiked/)
 * (@themiked)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/term-variable-not-working-in-shortcode/#post-6512185)
 * IIRC ‘term’ is not implemented as a shortcode. It’s only coded as a direct function
   call.
 *  Thread Starter [eSaner](https://wordpress.org/support/users/esaner/)
 * (@esaner)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/term-variable-not-working-in-shortcode/#post-6512186)
 * I couldn’t get it to work as a direct function call either. Ended up using a 
   the Categories Images plugin, which worked perfectly as both a direct function
   call and in a custom shortcode.
 *  Plugin Author [theMikeD](https://wordpress.org/support/users/themiked/)
 * (@themiked)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/term-variable-not-working-in-shortcode/#post-6512187)
 * Glad you found a solution.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘term variable not working in shortcode’ is closed to new replies.

 * ![](https://ps.w.org/genesis-taxonomy-images/assets/icon-128x128.jpg?rev=2222160)
 * [Genesis Taxonomy Images](https://wordpress.org/plugins/genesis-taxonomy-images/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/genesis-taxonomy-images/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/genesis-taxonomy-images/)
 * [Active Topics](https://wordpress.org/support/plugin/genesis-taxonomy-images/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/genesis-taxonomy-images/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/genesis-taxonomy-images/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [theMikeD](https://wordpress.org/support/users/themiked/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/term-variable-not-working-in-shortcode/#post-6512187)
 * Status: resolved