There is anyway that I can customize my search results? I mean, per example, I have a financial webpage I want to show all the results that includes the word "aapl" and "apple" if someone is searching for "aapl". How can I do this?

Thanks in advance


You can modify any query in pre_get_posts filter. So your code could looks like this:

function prefix_modify_search( $query ) {
    if( $query->is_search && $query->is_main_query() ) {
        $search = $query->get( 's' );
        $search .= '*';
        $query->set('s', $search);
add_action( 'pre_get_posts', 'prefix_modify_search' );

Note that the query parameter is passed as reference so you don't need to return it.

  • can I create a dictionary in order to use this? Like I need the name of the company and the stock ticker – juanora May 11 '15 at 11:06

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.