WordPress.org

Ready to get started?Download WordPress

Forums

WP Ultimate Search
[resolved] Can I use the posted search variables in my own custom php? (3 posts)

  1. adensmore
    Member
    Posted 10 months ago #

    Hi,

    I'm pretty new to customizing WP, so apologies in advance for anything obvious I'm not getting -

    I've got the WP Ultimate Search bar working great in the right-side widget area of my header. I'm directing the results to my "Search" page in "Pages".

    In "Pages", I'm using include me to load up some a custom lookup.php template:
    ie
    [wp-ultimate-search-bar]
    [wp-ultimate-search-results]

    [includeme file="lookup.php"]

    In "lookup.php", I'm trying to echo out the value of whatever the user typed into the search field of WP Ultimate Search.

    The idea is that I'd use that variable's value to do my own custom lookup against some custom database tables I've got, and return some simple results in my own format.

    So, I guess I really just used WP Ultimate Search for the good-looking bar in my widget area, and I'm sure that's an under-utilization of the power of WP Ultimate Search.

    But if you wouldn't mind telling me anyway if there's a simple variable you can give me the name of to get back the keyword typed into that field, ie

    $results
    $post
    $string
    $text
    $keywords
    $_POST[results]
    $_POST[post]
    $_POST[string]
    $_POST[text]
    $_POST[keywords]

    or whatever the variable name is that gets "test" if I just submit "test" to WP Ultimate Search, that'd be awesome!

    And if I'm way off how I should be doing this, I guess that'd be fair to tell me too. Ha

    Thank you very much!!

    http://wordpress.org/plugins/wp-ultimate-search/

  2. Bryce Corkins
    Member
    Posted 10 months ago #

    The data isn't sent through pages via $_POST, it's actually passed through the URL parameters which are parsed by backbone.js and populated into the search bar, so there's no easy way to directly grab the query before it's executed.

    You could make a custom results template (see http://mindsharelabs.com/ for instructions) and modify the appearance of the output any way you wanted.. but you'd still be relying on WPUS to conduct the database query.

    The other way to do it would be to somehow parse the current search URL in your includeme file and run your own search based on that.. but I'm not sure if you could do it with just PHP.

  3. adensmore
    Member
    Posted 10 months ago #

    I see Bryce, Okay --- thank you so much for taking the time for such a detailed reply, I really appreciate it !

    It sounds like I wouldn't really be putting your plugin to best use by trying to use it this way; I probably just need to handcode a simple php search form with input field, and put it in that widget area, and then pass it to my own custom template for results ...

    I will try to figure out the best way to do that!, some sort of custom php widget I imagine!

    Thanks again!,
    Alan

Reply

You must log in to post.

About this Plugin

About this Topic