Title: [Plugin: Shortcode Exec PHP] Get variables (not push) via Shortcode
Last modified: August 20, 2016

---

# [Plugin: Shortcode Exec PHP] Get variables (not push) via Shortcode

 *  Resolved Anonymous User 5580574
 * (@anonymized-5580574)
 * [15 years ago](https://wordpress.org/support/topic/plugin-shortcode-exec-php-get-variables-not-push-via-shortcode/)
 * Is there a possibility to get a variable I’ve stored in the php-plugin? Like **[
   shortcode arg=”value”]** …but vice-versa. For example: I have a shortcode-function
   called **[example]**
    and the following php-script:
 *     ```
       $variable1 = "text1";
       $variable2 = "text2";
       return $variable1 ." ". $variable2;
       ```
   
 * No problem, if I call the **[example]**-Shortcode, it will write “text1 text2”–
   BUT I’d like to have only the first variable.
 * The reason of my question is simple: I do use different shortcodes for those 
   who are guests, and those whoe are loggedin. Most of the php-script is the same
   and I have many (!) php-scripts, so it’s better not to duplicate the whole scripts
   and styling them every time again. I hope you got my ugly english 😀
 * Regards
    Sebastian

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

 *  Plugin Contributor [M66B](https://wordpress.org/support/users/m66b/)
 * (@m66b)
 * [15 years ago](https://wordpress.org/support/topic/plugin-shortcode-exec-php-get-variables-not-push-via-shortcode/#post-2092460)
 * I am not sure what you want, but you can pass arguments to a shortcode, take 
   a look in the [WordPress codex](http://codex.wordpress.org/Shortcode_API) for
   how to. It is also possible to store things, take a look at the [update_option](http://codex.wordpress.org/Function_Reference/update_option)
   function.
 *  Thread Starter Anonymous User 5580574
 * (@anonymized-5580574)
 * [15 years ago](https://wordpress.org/support/topic/plugin-shortcode-exec-php-get-variables-not-push-via-shortcode/#post-2092465)
 * Sorry, I’m not quite familiar with it and have problems to understand it. Hopefully
   you’ll get it now 😉 Let me do an example: In the article I write e.g. (I know,
   it’s the wrong code):
 * **[shortcode getthisvariableandpublish—>>>variable1]**
 * In the _shortcode exec php_-plugin I’ve added the shortcode called **shortcode**
   with the variable **$variable1**. There are other variables, so I cannot **return**
   them. I want just ONE variable… the **$variable1**.
 * The article should now proceed the text, which is included in the **$variable1**.
 *  Plugin Contributor [M66B](https://wordpress.org/support/users/m66b/)
 * (@m66b)
 * [15 years ago](https://wordpress.org/support/topic/plugin-shortcode-exec-php-get-variables-not-push-via-shortcode/#post-2092563)
 * I think you want something like this:
 *     ```
       extract(shortcode_atts(array('text' => 'default'), $atts));
       if ($text == 'a') return 'Text A';
       else return 'Text B';
       ```
   
 * `[shortcode text="a"]` -> ‘Text A’
 * `[shortcode text="b"]` -> ‘Text B’
 *  Thread Starter Anonymous User 5580574
 * (@anonymized-5580574)
 * [15 years ago](https://wordpress.org/support/topic/plugin-shortcode-exec-php-get-variables-not-push-via-shortcode/#post-2092565)
 * Wonderful! 🙂

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

The topic ‘[Plugin: Shortcode Exec PHP] Get variables (not push) via Shortcode’ 
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/shortcode-exec-php.svg)
 * [Shortcode Exec PHP](https://wordpress.org/plugins/shortcode-exec-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcode-exec-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcode-exec-php/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcode-exec-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcode-exec-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcode-exec-php/reviews/)

## Tags

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

 * 4 replies
 * 2 participants
 * Last reply from: Anonymous User 5580574
 * Last activity: [15 years ago](https://wordpress.org/support/topic/plugin-shortcode-exec-php-get-variables-not-push-via-shortcode/#post-2092565)
 * Status: resolved