Reputation: 3607
This is what I have / trying to achieve:
Example, I have post:
When user clicks on my 'ABC' post I would like him to be redirected to a corresponding url - 'http://test.com/123'.
Is there a plugin for that or maybe I could use some PHP code / DB modifications for that? Examples and suggestions are welcome!
P.S. I want the redirection to happen on every single post.
P.P.S. It is not suitable for me to redirect to the same constant url.
P.P.P.S. I really haven't found any good solutions on the web.
Upvotes: 2
Views: 1863
Reputation: 13840
There's a few plugins that can do what you're looking for.
One I wrote a while ago that gives you the option to bring the external content into your site -or- 301 redirect to it: Content Mask
One that works similarly, but just redirects: Page Links To
Or one that lets you handle it without going into each post: Simple 301 Redirects.
Alternatively, you could set a Custom Field on your posts with the external URL. Then, check if that value is set, and if so, redirect to the external URL, something like the following:
add_action( 'template_redirect', 'redirect_externally' );
function redirect_externally(){
$redirect = get_post_meta( get_the_ID(), 'redirect_to_here', true );
if( $redirect ){
wp_redirect( $redirect );
}
}
Upvotes: 3