Changeset 750
- Timestamp:
- 07/17/2014 07:11:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php
r746 r750 48 48 add_action( 'widgets_init', __NAMESPACE__ . '\\widgets_init' ); 49 49 add_action( 'pre_get_posts', __NAMESPACE__ . '\\pre_get_posts' ); 50 add_action( 'template_redirect', __NAMESPACE__ . '\\redirect_single_search_match' ); 50 51 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\theme_scripts_styles' ); 51 52 add_filter( 'post_type_link', __NAMESPACE__ . '\\method_permalink', 10, 2 ); … … 434 435 return $excerpt; 435 436 } 437 438 /** 439 * Redirects a search query with only one result directly to that result. 440 */ 441 function redirect_single_search_match() { 442 if ( is_search() && 1 == $GLOBALS['wp_query']->found_posts ) { 443 wp_redirect( get_permalink( get_post() ) ); 444 exit(); 445 } 446 } 447
Note: See TracChangeset
for help on using the changeset viewer.