Tagged: Search Bar
-
AuthorPosts
-
September 17, 2015 at 9:28 pm #505144
Hi team
i need to reduce the maximum number of characters in the search bar, but the script i pasted in functions.php file inside enfold-child is not working. Here what i have:
<?php
/*
* Add your own functions here. You can also copy some of the theme functions into this file.
* WordPress will use those functions instead of the original functions then.
*/function add_search_limit(){
?>
<script>
jQuery(window).load(function(){
jQuery(‘#top #s’).attr(‘maxlength’,’10’);
});
</script>
<?php
}
add_action(‘wp_footer’, ‘add_search_limit’);add_filter(‘avf_title_args’, ‘single_blog_page_title’, 10, 2);
function single_blog_page_title($args,$id) {
$pt = get_post_type( $id );
if(‘post’ == $pt){
$cat = get_the_category($id);
if(isset($category[0])) $args[‘title’] = $category[0]->cat_name;
}
return $args;}
Can you please give me a hand?
thanks in advance
September 18, 2015 at 6:57 am #505258Hey claraelisa!
Thank you for using Enfold.
Please replace the code with this:
add_action('wp_footer', function() { ?> <script> (function($) { $('#top #menu-item-search.menu-item-search-dropdown > a').click(function() { setTimeout( function() { $('#top #s').attr('maxlength','10'); }, 500); }); })(jQuery); </script> <?php });
Cheers!
IsmaelSeptember 18, 2015 at 4:27 pm #505648Hi Ismael
It works in the home page. i think we are so close to the final solution. I only need that scritp to work in this page
In the content temlate search is not working, either in the sidebar, because i can still write a lot of characters there.
I appreciate any help with this
September 19, 2015 at 5:11 am #505833Hi!
Please replace the code with this:
add_action('wp_footer', function() { ?> <script> (function($) { $('#top #menu-item-search.menu-item-search-dropdown > a').click(function() { setTimeout( function() { $('#top #s').attr('maxlength','10'); }, 500); }); $('#top #s').each(function() { $(this).attr('maxlength','10'); }); })(jQuery); </script> <?php });
Best regards,
IsmaelSeptember 21, 2015 at 2:44 pm #506446Wow that worked awesome.
thank you so much! I love enfold <3
Peace
-
AuthorPosts
- The topic ‘maximum characters in search bar’ is closed to new replies.