Completed

WordPress search results

I need four custom codes for the [url removed, login to view] files of four different wordpress sites.

The purpose is to limit the wordpress search results.

site 1) Search only at the beginning of the title (of post/page)

site 2) Search only at the end of the title (of post/page)

site 3) Search only within the title, i.e. excluding the first and last letter of the title (of post/page)

site 4) Search anywhere in the title (of post/page) considering the asterisks as unknown letters (for example, if I search for h*ll*, I will find hello)

I already have the following code in [url removed, login to view] to limit search to post/page titles only and exactly. It works fine.

function ni_search_by_title_only( $search, &$wp_query )

{

global $wpdb;

if ( empty( $search ) )

return $search; // skip processing - no search term in query

$q = $wp_query->query_vars;

$n = ! empty( $q['exact'] ) ? '' : '%';

$search =

$searchand = '';

foreach ( (array) $q['search_terms'] as $term ) {

$term = esc_sql( like_escape( $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;

}

add_filter( 'posts_search', 'ni_search_by_title_only', 500, 2 );

add_action('pre_get_posts', 'my_make_search_exact', 10);

function my_make_search_exact($query){

if(!is_admin() && $query->is_main_query() && $query->is_search) :

$query->set('exact', true);

endif;

}

Skills: PHP

See more: i need a fully responsive business website build in wordpress with amazing theme features it must be creative and best in design, improve wordpress search results page, wordpress customization instillation need, wordpress custom search query, wordpress search page plugin, wordpress search code, wordpress custom search form, wordpress display search results, divi search results page, wordpress search results plugin, wordpress search results page example, php, wordpress, web development, wordpress search results sort, wordpress small job need, need example bank statement, wordpress search results filter ajax price, wordpress search results max, wordpress search results per page

About the Employer:
( 0 reviews ) Italy

Project ID: #15460194

Awarded to:

€20 EUR in 1 day
(107 Reviews)
6.2

6 freelancers are bidding on average €24 for this job

Vadimwang

Having experience of PHP, I can do what you want. Relevant Skills and Experience PHP, Wordpress Proposed Milestones €23 EUR - 1 day

€23 EUR in 1 day
(2 Reviews)
1.9
€23 EUR in 1 day
(2 Reviews)
1.3
anatolygenay123

Hello. Don't worry about it Relevant Skills and Experience PHP Proposed Milestones €23 EUR - 1

€23 EUR in 1 day
(1 Review)
0.8
olasheni

Hey, I'm interested in your project. Please send me a message so that we can discuss more. Relevant Skills and Experience HTML CSS JavaScript PHP jQuery/AJAX SQL Laravel WordPress API Integration Shopify Integration W More

€23 EUR in 1 day
(1 Review)
0.8
notansolutions

A proposal has not yet been provided

€26 EUR in 15 days
(0 Reviews)
0.0