I have a section of my functions.php file (which is definitely running as I ran a die() and it showed.)

It is as follows:

function looky_setPermalink() {
add_action( 'init', 'looky_setPermalink' );  

And it doesn't seem to work when I go to looky/category/location, I just get told that it can not be found. Is there anything you can see that I might be doing wrong?



  • You flushed the rewrite rules, right...? – tfrommen Nov 5 '14 at 12:17
  • @tf I tried adding 'flush_rewrite_rules();' above my add_rewrite_rule and that didn't seem to make a difference (I hope I answered your question correctly) – Matthew Nov 5 '14 at 12:21
  • Sorry, I mean below, not above. – Matthew Nov 5 '14 at 12:30
  • your rule (sort of) works when I try it. you need to single-quote the query string argument rather than double-quote, so PHP doesn't try to expand the $matches vars, but it should still load the page with ID 4006 (which you've got in there twice by the way). make sure first that pretty permalinks in general are working, then verify it's not a plugin or theme conflict by disabling plugins and using a default theme. a quick way to flush your permalinks for testing is to visit the permalinks settings page in admin. – Milo Nov 5 '14 at 17:51

Did you add the query vars via the query_vars-hook in addition to the defintion of the rewrite rule in the init-hook?

add_filter( 'query_vars', 'my_add_query_var_function' );
function my_add_query_var_function( $vars ) {
    $vars[] = 'a';
    $vars[] = 'cat';
    $vars[] = 'where';
    return $vars;
|improve this answer|||||
  • This wasn't really my question but I understand why you thought it might be. – Matthew Nov 6 '14 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.