I can't find solution for this ...
URL: www.foo/some_page/?name=John
Page content:
Hi [Name]!
Worpress still redirects back to www.foo/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/some-page/?name=John
I can't find solution for this ...
URL: www.foo/some_page/?name=John
Page content:
Hi [Name]!
Worpress still redirects back to www.foo/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/some-page/?name=John
Share Improve this question edited Jul 24, 2014 at 0:18 Johannes P. 11.1k3 gold badges42 silver badges53 bronze badges asked Jul 23, 2014 at 20:00 Karel FundaKarel Funda 931 gold badge1 silver badge3 bronze badges 4 |2 Answers
Reset to default 7If 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.
We built a plugin that will do this for you https://wordpress/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.
function name_shortcode() { return (I don't know) $_GET['name']; } add_shortcode('Name', 'name_shortcode');
another page:Click here http://www.foo/some-page/?name=John
– Karel Funda Commented Jul 23, 2014 at 21:00