Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #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

    #505258

    Hey 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!
    Ismael

    #505648

    Hi 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

    View post on imgur.com

    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

    #505833

    Hi!

    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,
    Ismael

    #506446

    Wow that worked awesome.

    thank you so much! I love enfold <3

    Peace

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘maximum characters in search bar’ is closed to new replies.