Created
October 30, 2011 14:29
-
-
Save billerickson/1325958 to your computer and use it in GitHub Desktop.
Limit search to video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Limit Search to Video | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/wordpress-search-post-type/ | |
* | |
* @param string search form | |
* @param string search text | |
* @param string button text | |
* @return string modified search form | |
*/ | |
function be_search_limit($form, $search_text, $button_text) { | |
if( !( is_post_type_archive( 'video' ) || is_singular( 'video' ) ) ) | |
return $form; | |
$onfocus = " onfocus=\"if (this.value == '$search_text') {this.value = '';}\""; | |
$onblur = " onblur=\"if (this.value == '') {this.value = '$search_text';}\""; | |
$video_form = ' | |
<form method="get" action="' . get_option('home') . '/" > | |
<input type="text" value="'. $search_text .'" name="s"'. $onfocus . $onblur .' /> | |
<input type="hidden" name="post_type" value="video" /> | |
<input type="submit" value="'. $button_text .'" /> | |
</form> | |
'; | |
return $video_form; | |
} | |
add_filter('genesis_search_form', 'be_search_limit', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment