Append custom filter with get_post query in wordpress
add_filter( 'posts_where', 'wpse00001_posts_where', 10, 2 );
function wpse00001_posts_where( $where, &$wp_query )
{
global $wpdb;
if ( $wpse00001_title = $wp_query->get( 'wpse00001_title' ) ) {
$where .= ' AND UPPER(' . $wpdb->posts . '.post_title) LIKE UPPER(\'%' . esc_sql( $wpdb->esc_like( $wpse00001_title ) ) . '%\')';
}
return $where;
{
global $wpdb;
if ( $wpse00001_title = $wp_query->get( 'wpse00001_title' ) ) {
$where .= ' AND UPPER(' . $wpdb->posts . '.post_title) LIKE UPPER(\'%' . esc_sql( $wpdb->esc_like( $wpse00001_title ) ) . '%\')';
}
return $where;
No comments:
Post a Comment