Filter hook 'posts_search_orderby'

in WP Core File wp-includes/class-wp-query.php at line 2562

View Source

posts_search_orderby

Filter Hook
Description
Filters the ORDER BY used when ordering search results.

Hook Information

File Location wp-includes/class-wp-query.php View on GitHub
Hook Type Filter
Line Number 2562

Hook Parameters

Type Name Description
string $search_orderby The ORDER BY clause.
WP_Query $query The current WP_Query instance.

Usage Examples

Basic Usage
<?php
// Hook into posts_search_orderby
add_filter('posts_search_orderby', 'my_custom_filter', 10, 2);

function my_custom_filter($search_orderby, $query) {
    // Your custom filtering logic here
    return $search_orderby;
}

Source Code Context

wp-includes/class-wp-query.php:2562 - How this hook is used in WordPress core
<?php
2557  				 * @since 3.7.0
2558  				 *
2559  				 * @param string   $search_orderby The ORDER BY clause.
2560  				 * @param WP_Query $query          The current WP_Query instance.
2561  				 */
2562  				$search_orderby = apply_filters( 'posts_search_orderby', $search_orderby, $this );
2563  			}
2564  
2565  			if ( $search_orderby ) {
2566  				$orderby = $orderby ? $search_orderby . ', ' . $orderby : $search_orderby;
2567  			}

PHP Documentation

<?php
/**
				 * Filters the ORDER BY used when ordering search results.
				 *
				 * @since 3.7.0
				 *
				 * @param string   $search_orderby The ORDER BY clause.
				 * @param WP_Query $query          The current WP_Query instance.
				 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/class-wp-query.php
Related Hooks

Related hooks will be displayed here in future updates.