Title: Get URL from Shortcode 2
Last modified: October 11, 2020

---

# Get URL from Shortcode 2

 *  Resolved [hkpg123](https://wordpress.org/support/users/hkpg123/)
 * (@hkpg123)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/get-url-from-shortcode-2/)
 * Hi – I wanted to build upon this post:
 * Is there a way to only extract part of the URL??
    My domain is like this somebody.
   com/?referrer=ABC123 I just want to show the current URL’s referrer ID which 
   is ABC123
 * What part do I have to change in Vladimir’s code to change this to only show 
   the referral ID in my case?
 * Many thanks!!
 * **This was from 1 year ago – same forum and question**
 * brandimor (@brandimor)
    1 year, 11 months ago Is there a shortcode or a way to
   create a shortcode to get the current Site URL? I need it for when I develop 
   and move from one site to another and have not found a good way yet and this 
   seems like it might do the trick
 * Viewing 1 replies (of 1 total)
    Plugin AuthorVladimir (@gn_themes) 1 year, 11
   months ago Hi [@brandimor](https://wordpress.org/support/users/brandimor/),
 * there is no such shortcode, but you can easily create it yourself.
 * Add the following snippet to the end of the functions.php file of your active
   theme or into a site-specific plugin:
 * add_action( ‘init’, function() {
 *  add_shortcode( ‘site_url’, function( $atts = null, $content = null ) {
    return
   site_url(); } );
 * } );
    Then just use the following shortcode: [site_url]
 * Do not use this code on PHP version 5.2 or lower.
 * This reply was modified 1 year, 11 months ago by Vladimir. Reason:

The topic ‘Get URL from Shortcode 2’ is closed to new replies.

 * ![](https://ps.w.org/shortcodes-ultimate/assets/icon-256x256.gif?rev=2547563)
 * [Shortcodes Ultimate - Content Elements](https://wordpress.org/plugins/shortcodes-ultimate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcodes-ultimate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-ultimate/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-ultimate/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [hkpg123](https://wordpress.org/support/users/hkpg123/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/get-url-from-shortcode-2/)
 * Status: resolved