Title: Using shortcodes within the loop
Last modified: August 21, 2016

---

# Using shortcodes within the loop

 *  [indietravel](https://wordpress.org/support/users/indietravel/)
 * (@indietravel)
 * [12 years ago](https://wordpress.org/support/topic/using-shortcodes-within-the-loop/)
 * Trying to get a button from this plugin working inside the WP loop for post type.
 *     ```
       if ( shortcode_exists( 'bs_button' ) ) {
   
        				echo do_shortcode('[bs_button size="lg" type="default" value="Read More" href=""]');
   
       			} else {
       				// fail silently
       			}
       ```
   
 * This is working well, but _how_ do we get the permalink into that href variable?
   I’ve tried
 * `echo do_shortcode('[bs_button size="lg" type="default" value="Read More" href
   ="get_permalink();"]');`
 * `echo do_shortcode('[bs_button size="lg" type="default" value="Read More" href
   =" '. get_permalink() .' "]');`
 * But I feel this is the wrong approach. Could it work, or is there another way
   to make this work?
 * [https://wordpress.org/plugins/bootstrap-shortcodes/](https://wordpress.org/plugins/bootstrap-shortcodes/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [indietravel](https://wordpress.org/support/users/indietravel/)
 * (@indietravel)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/using-shortcodes-within-the-loop/#post-4960858)
 * The following works for me:
 * `echo do_shortcode('[bs_button size="lg" type="default" value="Read More" href
   ="'. get_permalink() .'"]');`

Viewing 1 replies (of 1 total)

The topic ‘Using shortcodes within the loop’ is closed to new replies.

 * ![](https://ps.w.org/bootstrap-shortcodes/assets/icon.svg?rev=1034009)
 * [Bootstrap Shortcodes](https://wordpress.org/plugins/bootstrap-shortcodes/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bootstrap-shortcodes/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bootstrap-shortcodes/)
 * [Active Topics](https://wordpress.org/support/plugin/bootstrap-shortcodes/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bootstrap-shortcodes/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bootstrap-shortcodes/reviews/)

## Tags

 * [do_shortcode](https://wordpress.org/support/topic-tag/do_shortcode/)
 * [variables](https://wordpress.org/support/topic-tag/variables/)

 * 1 reply
 * 1 participant
 * Last reply from: [indietravel](https://wordpress.org/support/users/indietravel/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/using-shortcodes-within-the-loop/#post-4960858)
 * Status: not resolved