WordPress.org

Ready to get started?Download WordPress

Forums

Custom Query Var handling (3 posts)

  1. adhardwick
    Member
    Posted 2 years ago #

    I am using google Adsense for search.
    On form submit the action adds a query var string that starts with "?cx="

    I want that action to be handled by a file in theme called results.php (instead of search.php or the fallback index.php). Does anyone know how this can be done?

    Maybe a filter to add cx to query vars and the a filter to define is_results function?

  2. Mark / t31os
    Moderator
    Posted 2 years ago #

    Run a filter on template_include, check for your query var, if it's present, switch the template to your custom one.

    Dump the passed variable inside a callback on that filter before returning it and you'll see what i mean(assuming you know the basics of how filters work).. ;)

    You can see the filter in source here, incase it helps.
    http://core.trac.wordpress.org/browser/tags/3.3/wp-includes/template-loader.php

  3. adhardwick
    Member
    Posted 2 years ago #

    Thanks Mark,

    That's the file I had been scrutinizing. Just taking the week of for vacation.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags