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 https://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
- The topic ‘term variable not working in shortcode’ is closed to new replies.