Adding custom URLs
-
Hey all,
I’m in dire need of some sanity here. I’ve been playing about with this for hours, and don’t understand the slightest of my issue.
I’m trying to add custom links into my plugin, so that my site doesn’t look so nasty. I have the pages currently working using $_GET (sortof… if I refresh a page that seems to break, and sometimes randomly fails).
I’ve done the usual search all over the web, and found several sites which cover it, but copying them doesn’t seem to work for me.
Here’s my code:register_activation_hook(__FILE__,'do_flush_gear'); function do_flush_gear() { global $wp_rewrite; $wp_rewrite->flush_rules(); } function add_my_loc_var($public_query_vars) { $public_query_vars[] = 'locale'; return $public_query_vars; } add_filter('query_vars', 'add_my_loc_var'); function do_rewrite_urls() { add_rewrite_rule('accommo/(.+)/?$', 'index.php?pagename=locations&location=$matches[1]','top'); } add_action('init', 'do_rewrite_urls');Currently my site uses this for the pages: “http://www.c2c-guide.co.uk/locations/?location=Whitehaven”
and I’d like to change that to be “http://www.c2c-guide.co.uk/accommo/Whitehaven” but for whatever reason the code listed above doesn’t work, and instead that takes me to “http://www.c2c-guide.co.uk/locations/directions/whitehaven-directions/”Can anyone help me solve this problem, and shed some light on the issue?
The topic ‘Adding custom URLs’ is closed to new replies.