1

I am writing a plugin that utilizes URL parameters. For some reason, adding one of these parameters to the home page of my website causes a 404 (http://bleaney.ca/?source=asdf). Adding the parameter to any other page, however, doesn't cause a 404 (http://bleaney.ca/work-experience-2/?source=asdf). This 404 issue only manifested itself after I registered the parameter with Wordpress:

add_filter('query_vars', 'register_visitor_identifier_query_vars' );
function register_visitor_identifier_query_vars( $qvars ) {
    $qvars[] = 'source';
    return $qvars;
}

On the 404 page, the URL parameter is still detected by this code, the page itself just 404s for some reason:

if (isset($wp_query->query_vars['source'])) {
    echo $wp_query->query_vars['source'];
}

Any idea what is causing this and how I can fix it? I think the workaround of just setting the home page to have a longer ULR like the work experience link would work, but I'd rather fix this issue if possible, rather than work around it.

  • Where are you adding this filter to? – Rarst Dec 19 '13 at 16:19
  • Any luck here? I'm having the same issue with 404s on the homepage after modiflying the $wp->query_vars object via the parse_request hook in WP – Devin Walker May 25 '14 at 22:16
  • I actually found the code that was the issue, so I've modified my own version of wordpress. I still need to figure out the process for submitting a patch though. – GBleaney May 27 '14 at 13:41
0

I was having this same issue. I found that the issue was caused because I had set the front page to display a static page for the front page and another for the posts page. (Set in Reading Settings)

enter image description here

However, my posts page had been deleted. In this case because we decided not to have a posts page any more. The URL variables were trying to switch the home page view to the posts page that did not exist.

I fixed this by updating my template to use front-page.php (rather than a page template) and changed the setting so that the front page displays Your latest posts.

enter image description here

This solution worked for me because I did not need the posts page.

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.