JavaScript Redirect Template

a marvel of modern programming is this little wordpress page template that like the common redirect.php redirects from the page if the custom field “redirect” is set to an url but does so with a lil javascript.

and if u have no clue why you would need this if there is allready redirect.php then you wont need it, but if LimitInternalRedirect tells u anything you might guess it.

code

<?php
/*
Template Name: JavaScript Redirect
*/
 
if (have_posts()) : while (have_posts()) : the_post();
 
	$redirect_meta_key = "redirect";
	for ($i = 0; $i < 2; $i++) {
		$redirect = get_post_meta($wp_query->post->ID, $redirect_meta_key, true);
		if('' != $redirect) { ?>
 
<script language="JavaScript">
	window.location = "<? echo $redirect; ?>";
</script>
			
		<?php }
		$redirect_meta_key = "Redirect";
	}
 
endwhile; endif;
?>

download

 
wordpress/javascriptredirect.txt · Zuletzt geändert: 2007/11/30 01:12 von n00bian
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki