[wp-hackers] Plugin replacing a page based on http variables

Alex Günsche ag.ml2007 at zirona.com
Thu Sep 20 10:56:05 GMT 2007


On Thu, 2007-09-20 at 11:41 +0100, James Davis wrote:
> I'm writing my first serious plugin and I'd like to overide the normal
> output of WordPress with a page of content displayed in the selected
> theme but defined by the plugin. Specifically I'm looking to display
> some particular content at a URL like the following.
> 
> http://www.mywpblog.org.uk/?confirm=12345
> 
> What hook/action do I need to be looking at to achieve this?

The template_redirect hook will replace the actual output with yours.

<?php
function mycontent() {
	if ('bar' == $_GET['foo']) {
		?>
		<html>
			<head>
				<title>foo</title>
			</head>
			<body>
			foobar
			</body>
		</html>
		<?php
		exit; // important!
	}
}
add_action('template_redirect', 'mycontent');
?>


Kind regards,
Alex

-- 
Alex Günsche, Zirona OpenSource-Consulting
Blogs: http://www.zirona.com/ | http://www.regularimpressions.net
PubKey for this address: http://www.zirona.com/misc/ag.ml2007.asc



More information about the wp-hackers mailing list