Focus on cloud service provider activities
Notes on website operation and maintenance

Solve the problem of "search_by_title_only() expected to be a reference" on the website

Because of the PHP version, some of our friends may enable compatibility without reporting errors, so we can't see some problems. However, with the increase of logs, the server disk will be occupied. The PHP log prompts "search_by_title_only() expected to be a reference". How can I solve this problem?

 //PHP error reporting by laozuo.org add_filter('posts_search', 'laozuoorg_search_by_title_only', 500, 2); function laozuoorg_search_by_title_only($search) { global $wpdb, $wp_query; if (empty($search)) return $search; $q = $wp_query->query_vars; $n = ! empty($q['exact']) ? '' : '%'; $search = $searchand = ''; foreach ((array) $q['search_terms'] as $term) { $term = esc_sql($wpdb->esc_like($term)); $search .=  "{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')"; $searchand = ' AND '; } if (!empty($search)) { $search = " AND ({$search}) "; if (!is_user_logged_in()) $search .=  " AND ($wpdb->posts.post_password = '') "; } return $search; }

 

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Solve the problem of "search_by_title_only() expected to be a reference" on the website