Title: Pass parameter to shortcode
Last modified: April 20, 2022

---

# Pass parameter to shortcode

 *  [Roger Correia](https://wordpress.org/support/users/correiar/)
 * (@correiar)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/pass-parameter-to-shortcode-2/)
 * We use a plugin to display user feedback surveys on a page as follows:
    [ays_survey
   id=’17’].
 * I want to be able to pass a parameter to the page to change the survey ID using:
   [
   urlparam param=”SurveyID”]
 * How can I insert the passed parameter into the first shortcode above?
 * Please advise. Thanks

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

 *  Thread Starter [Roger Correia](https://wordpress.org/support/users/correiar/)
 * (@correiar)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/pass-parameter-to-shortcode-2/#post-15582628)
 * You may close this thread. I resolved the issue using a PHP snippet that uses
   do_shortcode to retrieve the parameter passed via URL.
 *  [sdp1960](https://wordpress.org/support/users/sdp1960/)
 * (@sdp1960)
 * [4 years ago](https://wordpress.org/support/topic/pass-parameter-to-shortcode-2/#post-15673879)
 * Hi Roger, have you solved your problem?
    I hacve a similar one, I need to pass
   a filename via url partam to a shortcode of a pdf viewer.
 * something like your survey_id
 *  Thread Starter [Roger Correia](https://wordpress.org/support/users/correiar/)
 * (@correiar)
 * [4 years ago](https://wordpress.org/support/topic/pass-parameter-to-shortcode-2/#post-15675231)
 * I use a PHP Snippet plugin: [https://wordpress.org/plugins/insert-php-code-snippet/](https://wordpress.org/plugins/insert-php-code-snippet/)
 * I then create the URL Params shortcode using PHP code and execute the newly created
   shortcode using do_shortcode as shown below:
 * <?php
    $parm1=”[ays_survey “; $parm2=”id='” . $surveyid . “‘”; $parm3=”]”; $shortcode
   =”{$parm1}{$parm2}{$parm3}”; echo do_shortcode($shortcode); ?>

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

The topic ‘Pass parameter to shortcode’ is closed to new replies.

 * ![](https://ps.w.org/url-params/assets/icon-128x128.png?rev=979780)
 * [URL Params](https://wordpress.org/plugins/url-params/)
 * [Support Threads](https://wordpress.org/support/plugin/url-params/)
 * [Active Topics](https://wordpress.org/support/plugin/url-params/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/url-params/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/url-params/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Roger Correia](https://wordpress.org/support/users/correiar/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/pass-parameter-to-shortcode-2/#post-15675231)
 * Status: not resolved