![]() |
Hello!
I'm looking for a solution for the following scenario:
When I link to external pages, I want to link to an exit page, which displays a goodbye message for a few seconds, and then automatically transfers the visitor to the external url.
You've probably seen it:
"You are now being redirected to blablabla, if nothing happens you can click the link below".
The problem:
I don't want to link directly to the external url. Instead I want to link to the exit page, and pass the post id as a paramenter. Something like this:
http://mywebsite.com/exit.php?=426
Where 426 is the post ID.
THEN, I would like to fetch the external url from a custom field in the original post.
So:
I need some kind of page template and when I link to this page i can pass the post id as a paramenter or something. Then the page template uses the post id and retrieves the value of a custom field from the post.
I want it to redirect after a few seconds, just have enough time so the visitor can read my Goodbye message!
Thank you!
// Jens.
Solution - 1Hello, what you're trying to do is fairly simple. It can be accomplished without a page template. We'll have to intrudoce a new query variable, for example 'exit'. So then you'd link to http://example.com/?exit={post_id} Let's go through setting that up. First we register the new query var: Then, we tell WP to load a special template: Then we create the actual template file in the theme directory:
Solution - 2You will need something like this: exit.php $value ) { echo "You are going to be redirected to: " . $value; // sleep 5 seconds // redirect to $value } ?> Solution - 3in the link pass the ?postID as the paramete , like below url http://mywebsite.com/exit.php?postID=426 click here'; ?> |
Wordpress |
Type: | Code Example |
Category: | Coding |
Sub Category: | Code Example |
Uploaded by: | Admin |
Views: | 8 |