[wp-hackers] Help for Plugin Noob

Eric Hochberger mailinglists at yournextbroker.com
Fri Jan 27 21:28:30 GMT 2006


Hey guys,

I'm trying to get into writing wordpress plugins.  Writing my first  
one now!  However, I'm having a lot of trouble getting it to work  
with mod rewrite.  I'm running the latest version of wordpress 2.0.1  
(rc1).

Maybe someone can tell me what I'm doing wrong?  I'd really  
appreciate it!

Also, when I type in the query ?ld_home=1, the template does load  
correctly.  It's just the mod rewrite that is not working.

Code to at the bottom:

Thanks,
Eric



------

function ld_rewrite_rules($old_rules)
{
	$my_rules['directory/'] = '/index.php?ld_home=1';
	
	return array_merge($my_rules, $old_rules);
}
add_filter('rewrite_rules_array','ld_rewrite_rules');



function ld_query_var(&$query_vars)
{
	$query_vars[] = 'ld_home';
	
	return $query_vars;
}
add_filter('query_vars','ld_query_var');

function ld_template()
{
	
	$template= false;
	
	if (get_query_var('ld_home') != "") {	
	
		$template = "ld_home.php";
	}
	
	if ($template) {
	
		$template_dir = ABSPATH . 'wp-content/themes/' . get_settings 
('template');
		if (file_exists($template_dir . '/ld_home.php') ) {
			include($template_dir . '/ld_home.php');
			exit;
		} else {
			include(ABSPATH . 'wp-content/plugins/linkingdirectory/templates/ 
ld_home.php');
			exit;
		}
		return;
	
	}
}
add_action('template_redirect','ld_template');


---------



More information about the wp-hackers mailing list