F. Ramiro-Manzano, website logo

Search inside current category or tag

The following php code permits to seach using Wordpress (and in my case Oxygen builder) inside of the current category or tag.
I'm far to be an expert in php, Iknow only the basics. This code is a modification (including tags) of the one posted by gmazzap in the MasWordpress forum:
https://maswordpress.info/questions/19647/cuadro-de-busqueda-de-categoria-personalizada-para-wordpress 
You can watch how it works in this site.
Acknowledgements: gmazzap (MasWordpress))

php code:

<?php
$term = null;
$CorT_term_id = null;
$CorT_term_name = null;
$Is_a_cat=false;
$del_s=get_search_query();
if (empty($del_s)){$del_s="type here";}
$btn = __('Search');
if ( is_tag() ) {
$term = get_queried_object();
//echo $term->name;
$CorT_term_id = "tag";
$CorT_term_name = "tag";
}
if ( is_category() ) {
$term = get_queried_object();
$CorT_term_id = "cat";
$CorT_term_name = "category_name";
}
?>
<form method="get" id="search_form" action="<?php echo home_url(); ?>">
<div id="buscar_bloque1">
<input type="text" value="<?php echo $del_s; ?>" name="s" id="s" />
</div>
<?php
if ($term) {
$btn = sprintf( __('Search in this: %s'), $term->name);
?>
<?php if ($Is_a_cat){ ?>
<input type="hidden" value="<?php echo $term->term_id; ?>" name="<?php echo $CorT_term_id; ?>" />
<?php } ?>
<input type="hidden" value="<?php echo $term->name; ?>" name="<?php echo $CorT_term_name; ?>" />
<?php } ?>
<div id="buscar_bloque2">
<input type="submit" id="search_submit" value="Search">
</div>
</form>
Fernando Ramiro Manzano, PhD 
Email:
ferraman(at)fis.upv.es
Substitute (at) with @
Phone:
(+34) 96 387 9841
Address:
CTF-ITQ, UPV, Edificio 8B, Avda. Los Naranjos SN, 46360 - Valencia, Spain
This website has been created using Wordpress and the Oxygen builder. To achieve parallax effects, the Vanilla Javascript Parallax Library 'Rellax' (Dixon & Moe) was utilized. Most of the graphical content, such as icons and images, has been created specifically for this website, with the exception of the link favicons and journal copyright material, which have been used with permission from their respective publishers. If there are any questions ir problems regarding permissions, please do not hesitate to contact me.

Thank you for visiting my Website.
Fernando.
LOGO Nanomaterials for optoelectronics, photonics and energy, ITQ, CSIC, UPV, Severo Ochoa