Title: Echo do_shortcode with variable
Last modified: August 21, 2016

---

# Echo do_shortcode with variable

 *  [zecke](https://wordpress.org/support/users/zecke/)
 * (@zecke)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/echo-do_shortcode-with-variable/)
 * Hi
 * I got this code:
 * `<?php $terms = get_the_terms( $post->ID , 'category' );foreach ( $terms as $
   term ) {$term_link = get_term_link( $term, 'category' ); echo $term_link;} ?>`
 * That echo me category slug in $term_link variable
 * Now I want to put the variable in xxx place:
 * `<?php echo do_shortcode( '[gallery category="xxx"]' ) ?>`
 * Can You help me and span those two codes into one properly ?
 * Thank You in advance

Viewing 1 replies (of 1 total)

 *  [J M](https://wordpress.org/support/users/hiphopinenglish/)
 * (@hiphopinenglish)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/echo-do_shortcode-with-variable/#post-4388882)
 * Can’t you just move the `echo $term_link` to inside the shortcode?

Viewing 1 replies (of 1 total)

The topic ‘Echo do_shortcode with variable’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [J M](https://wordpress.org/support/users/hiphopinenglish/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/echo-do_shortcode-with-variable/#post-4388882)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
