• ArkaneArkade

    (@arkanearkade)


    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Any particular reason you aren’t using Pretty Permalinks?

    Thread Starter ArkaneArkade

    (@arkanearkade)

    It does have pretty permalinks enabled, but the plugin itself needs the location $_GET. My hope is to get this working to remove that question mark once and for all, since it’s only the plugin which uses it.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding custom URLs’ is closed to new replies.