Title: stuck- shortcode inside php that is inside php?
Last modified: August 20, 2016

---

# stuck- shortcode inside php that is inside php?

 *  [destova5](https://wordpress.org/support/users/destova5/)
 * (@destova5)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/stuck-shortcode-inside-php-that-is-inside-php/)
 * I know how to call a shortcode inside php. I know how to get_template_part() 
   in php. But how do I combine the two??
 * I’m using urlparams plugin to make a dynamic newsletter page for a client. So
   far so good- it injects the schoolname into the content easily and I figured 
   out how to inject the correct school banner image using the php echo do_shortcode.
 * But- now I need to pull in a custom template part based on the schoolname variable
   with urlparam. This has been stopping me at every turn.
 * When I do this:
    `<?php get_template_part( '. echo do_shortcode('[urlparam param
   ="schoolname" /]').'); ?>`
 * I get an unexpected error for the [
 * When I do this,
    `<?php get_template_part( 'echo .urlparams(param="schoolname").');?
   >`
 * I don’t get the errors, but the links do not show up in the page…
 * Can someone please tell me if what I am doing is impossible or if I’m missing
   something… I planned to have a php file for each school so that it was just a
   little section being included in the page with their school specific links.
 * thank you!!
 * ((Probably way too much extra info, but in case you need it, the first page in
   which they choose their school and the url param is passed is [http://www.lunchtimesolutions.com/new/index.php/district-newsletters](http://www.lunchtimesolutions.com/new/index.php/district-newsletters)
   and the page that I’m having issues pulling the template part into is [http://www.lunchtimesolutions.com/new/index.php/current-newsletter](http://www.lunchtimesolutions.com/new/index.php/current-newsletter)–
   and the test file I set up for the schools is for Vermillion school, located 
   here: [http://www.lunchtimesolutions.com/new/wp-content/themes/twentyten/Vermillion.php](http://www.lunchtimesolutions.com/new/wp-content/themes/twentyten/Vermillion.php)))

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/stuck-shortcode-inside-php-that-is-inside-php/#post-3155203)
 * no need to _**echo **_– `do_shortcode()` returns a string which you can concatenate
   with the other `get_template_part()` strings;
 * example (untested as I don’t have the shortcode and test data)):
 *     ```
       <?php get_template_part( do_shortcode('[urlparam param="schoolname" /]') ); ?>
       ```
   
 *  Thread Starter [destova5](https://wordpress.org/support/users/destova5/)
 * (@destova5)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/stuck-shortcode-inside-php-that-is-inside-php/#post-3155215)
 * omg… THANK YOU!!!!!!!
 * I had found a post about including shortcode in php and it had the echo bit in
   it- I thought it was required.
 * And it works- you are wonderful! Thank you so much 🙂

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

The topic ‘stuck- shortcode inside php that is inside php?’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [destova5](https://wordpress.org/support/users/destova5/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/stuck-shortcode-inside-php-that-is-inside-php/#post-3155215)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
