Title: Pass a variable from a shortcode
Last modified: August 19, 2016

---

# Pass a variable from a shortcode

 *  [thekruser](https://wordpress.org/support/users/thekruser/)
 * (@thekruser)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/pass-a-variable-from-a-shortcode/)
 * **Long story short:**
    I need to use an attribute from a shortcode outside of
   the shortcode function. I am _very_ new at .php and I am not sure how to proceed.
 * **The long story:**
    I have a database (separate from the WP database) that I
   store information in to be retrieved by posts/pages. Currently, I am using this
   database to generate html that I copy/paste into my WP pages.
 * I have written a series of .php pages that retrieves the information I need in
   my posts/pages. Now I just need to have them display in WP. I figured the easiest
   way was to use a shortcode to call the page to load. I am using the _Shortcode
   Exec PHP_ plugin with the following code:
 *     ```
       extract(shortcode_atts(array(
       		'type' => 'list',
       		'id' => 'alpha',
       	), $atts));
       require_once( '(link to the page to be loaded)' );
       ```
   
 * I need to pass `$type` and `$id` to the .php page called from the function to
   determine what path/series of .php files are executed in what order.
 * Please let me know if I am not being descriptive enough in my explanation. I 
   have been trying to get this done for about a week now and am at my wits end.
 * Thank you in advance for your time and help. Have a great day!

Viewing 1 replies (of 1 total)

 *  [lerizzle](https://wordpress.org/support/users/lerizzle/)
 * (@lerizzle)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/pass-a-variable-from-a-shortcode/#post-1835120)
 * Did you ever get the answer to this?

Viewing 1 replies (of 1 total)

The topic ‘Pass a variable from a shortcode’ is closed to new replies.

## Tags

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

 * 1 reply
 * 2 participants
 * Last reply from: [lerizzle](https://wordpress.org/support/users/lerizzle/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/pass-a-variable-from-a-shortcode/#post-1835120)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
