WordPress.org

Forums

Echo do_shortcode with variable (2 posts)

  1. zecke
    Member
    Posted 1 year ago #

    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

  2. J M
    Member
    Posted 1 year ago #

    Can't you just move the echo $term_link to inside the shortcode?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.