WP Query | search by sub-categories

I have a small problem with the functioning of a search bar that gives the user the possibility to find professionals based on their job categories.

I explain: I am talking about a portal that allows the user to be able to carry out a search as written above.

How I managed the programming: if it is a portal where there are professionals, I created the custom post type: Pro

To specify the services that these professionals are able to perform, I created a plugin that allows me by specifying in the array which custom post types to grant the possibility to implement taxonomies:

register_taxonomy( 'categoria', array( 'pro' ), $  args ); 

now very simply I have implemented a form on a page:

<div id="search_video"  class="container-fluid">     <div style="text-align: center;background-color: #fff;" class="col-md-12">         <form name="NOME_FORM" method="get" id="advanced-searchform" role="search" action="<?php echo esc_url( home_url( '/results' ) ); ?>">             <div class="input-group mb-3">                 <div class="input-group-prepend">                     <span class="input-group-text"><i class="fa fa-search"></i></span>                 </div>                 <input type="text" id="art" name="art" class="form-control">             </div>         </form>     </div>     </div> </div> 

pointing to the results page.

to display the results I used this query:

<?php $  art_p = $  _GET['art'];         $  query_v = array(             'post_type' => array('pro'),             'posts_per_page'    => -1,             'orderby' => 'meta_value',             'order' => 'ASC',             'tax_query' => array(                 array(                     'taxonomy' => 'categoria',                     'terms' => $  art_p,                 )             )         );         $  res_v = new WP_Query( $  query_v );         ?> 

now the problem:

I have implemented two test professional profiles, in the services category, I have specified as a sub-category of services for professional A:

  • creation of websites

and for professional B:

  • logo creation

but if I look in the website creation bar: it gives me both professionals as a result and this is not good.

So my question is how can I filter the results so that the user search is based on the sub-category of services and only brings out the professionals who own that sub-category, what did I do wrong with my query?

WordPress Admin Post Search extend to one custom field

I would like to extend the WordPress admin post search (so in back-end) in order to look at keywords in post title but also in one custom field.

I find this thread interesseting (except the custom post type because I don’t use it) : Extending the search context in the admin list post screen and adapt my function like below :

function rel_search_join( $  join ) {     global $  pagenow, $  wpdb;     if ( is_admin() && $  pagenow == 'edit.php' && $  _GET['post_type'] == 'post' && $  _GET['s'] != '') {             $  join .= 'LEFT JOIN ' . $  wpdb->postmeta . ' ON '. $  wpdb->posts . '.ID = ' . $  wpdb->postmeta . '.post_id ';     }     return $  join; } add_filter('posts_join', 'rel_search_join' );  function rel_search_where( $  where ) {     global $  pagenow, $  wpdb;     if ( is_admin() && $  pagenow == 'edit.php' && $  _GET['post_type']=='post' && $  _GET['s'] != '' ) {         $  where = preg_replace( "/\(\s*".$  wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/", "(".$  wpdb->posts.".post_title LIKE $  1) OR (".$  wpdb->postmeta.".my-custom-field-meta-key LIKE $  1)", $  where );         $  where = str_replace( "OR wp_posts.post_status = 'pending'", "", $  where );         $  where = str_replace( "OR wp_posts.post_status = 'private'", "", $  where );         $  where = str_replace( "OR wp_posts.post_status = 'draft'", "", $  where );         $  where = str_replace( "OR wp_posts.post_status = 'future'", "", $  where );     }     return $  where; } add_filter( 'posts_where', 'rel_search_where' ); 

But this does not work at all, the search was no longer working at all.

I feel like there is a way easier solution but I am not able to find it on any forums.

I know there are other solutions like custom field filters but it is not suitable for my custom field which can have thousands of values.

PS : I use Advanced Custom Field but I don’t think there is any connection.

How to stop Google search, by using “noindex” and “nofollow,” from offering options to private pages on a website

I have a family history website, call it "my_family.com". The primary file, index.php, has some introductory remarks of explanation and an html form into which one puts the website’s password (there’s a single password used by all family members). If one runs "my_family.com" and inserts the correct password and clicks on the "Submit" button, the php code in the file takes you to the first of several html files — call it "first.html," which gives one links to further html files. All of these files contain family trees, copies of letters, photos, reminiscences, obituaries, etc., and none of which should be available to non-family-members. I soon found out found that if one put the phrase "my_family.com" into the Google search window (whether on computer of smartphone), one got a list of options, not just a Login option but about eight to ten 3-4 word excerpts from html files on the website; and if one clicked on any of these latter options, one bypassed the password process and was taken directly to other files on the website, i.e., files that should never be publicly revealed.
What I’ve done to avoid such access is to create a cookie in the original index.php file. If the user inserts the correct password, the cookie is set to "passwordCorrect" Each subsequent html file then checks whether the cookie has that value before the user is allowed to move on Putting in the cookies has solved the problem of public access, but nevertheless a Google search still shows the 3-4 word excerpts. I have tried to stop Google search from doing this by putting into the header section of first.html: ”” (without the outer quotes). But that has been in the file for about three weeks and has proved useless. I tried using Google Search Console to get Google to make an early "crawl" of the file my_family.com, but am frustrated by the lack of examples about how to use it, and don’t think I succeeded. Maybe I should be asking for a crawl of the file my_family.com/first.html, instead of the basic my_family.com website? I’d appreciate any advice anyone has about this. For example, how do I determine when the last crawl was, when can I expect the next crawl, is the meta tag in the correct file, etc? Thanks

Tweak the WP Query search

I am having a hard time trying to find a way to tweak the search option on my wordpress website. For example: I have products with the word electronic in the title, however when people search with the word electronics (plural) it won’t pull the results of all the products containing the title electronic and I guess that’s not good. Probably I’m loosing potential buyers. Any idea how to tweak that? Thank you!