WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to wordpress and need to modify the default search functionality. What file do I have to look for or provide me with some tutorials..

Any help would be much appreciated

share|improve this question

Modify the searchform.php, or create one in a child theme (recommended), and you should be able to modify the form all you want.

The default HTML is in /wp-includes/general-template.php, to which I have already linked, but don't edit that. It is a Core file. Copy the markup into your searchform.php if you need a place to start.

Please refer this link to modify search function detail.

Also refer this link for adding custom post type in search.

share|improve this answer
Please use a little more descriptive anchors than "this link", it makes answer more readable and easier to know where link leads to. – Rarst Nov 21 '13 at 11:00

Example - http://codex.wordpress.org/Function_Reference/register_post_type#Example

(ensure you have these parameters true :

'publicly_queryable' => true, 'query_var' => true,

then you might need to have this function to include search code in functions.php for custom post types:

function search_filterr($query) 
    if ( !is_admin() && $query->is_main_query() ) 
            global $cts,$lang; $arrs=array(); foreach($cts['post_Typess'] as $befefeb) {$arrs[]=$befefeb;}
            if ( $query->is_search ) 
                $query->set('post_type',  $arrs );

                    //include only specific categories
                    //global $sxvaa,$lang;
                    //$query->set('cat', '' );

                $query->set('post_type', $arrs  );
        return $query;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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