I can't find solution for this ...

URL: www.foo.com/some_page/?name=John

Page content:

Hi [Name]!

Worpress still redirects back to www.foo.com/some_page/

I tried everything ...

I need something like the following in functions.php

function name_shortcode() {
    return $_GET['name'];
add_shortcode( 'Name', 'name_shortcode' );

And on another page: Click here www.foo.com/some-page/?name=John

  • please show the code for "some_page". It's impossible to help you without seeing any code. And what shortcode are you using?
    – gdaniel
    Jul 23, 2014 at 20:24
  • I tried everything ... (I deleted code) I need some like in functions.php function name_shortcode() { return (I don't know) $_GET['name']; } add_shortcode('Name', 'name_shortcode'); another page: Click here http://www.foo.com/some-page/?name=John Jul 23, 2014 at 21:00
  • You can edit your question, rather than adding information as a comment. Jul 24, 2014 at 0:18
  • That being said, when dies WordPress redirect to www.foo.com/some_page/? Jul 24, 2014 at 0:19

2 Answers 2


If I understand your question correctly, you want to be able to get the parameter from the url, add it to the shortcode so you can add the parameter to the content.

See if this works:

add_shortcode('name', 'get_name');

function get_name() {

   return $_GET['name'];


In the wordpress backend editor you would have something like:

Hello [name], Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.

  • This not work because Wordpress redirect url: www.foo.com/page/?names=john to www.foo.com/page/ and parameter names is empty. Jul 23, 2014 at 21:40
  • Maybe you have some plugin that's redirecting or the theme was created that way. I tested on a couple of sites I built and it didn't redirect. Wordpress usually redirects if you are trying to do it on the front-page/home/root because that's by default used for the search results.
    – gdaniel
    Jul 23, 2014 at 21:56
  • 1
    You are Great! One plugin was redirecting. Thank You for help. Jul 24, 2014 at 4:25

We built a plugin that will do this for you https://wordpress.org/plugins/display-url-params/ - It uses a simple shortcode to get URL parameters from the Query String and display them as dynamic content on pages and posts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.