• Hi,

    I would like to change the text that appears in the search bar (“Seach…”), and most importantly remove the italics.

    Would you know how to do this?

    Thank you very much for your help.
    v.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hey there vikou1008,

    How are you doing today?

    Removing the italics should be easily done with some custom CSS. To do that please try adding the following CSS code in the style.css file of your child theme or if your theme doesn’t have custom CSS tab add it in your site using the following plugin:

    http://wordpress.org/plugins/simple-custom-css

    #search-wrapper input[type="search"] {
        font-style: initial;
    }

    This should remove the italic part from the placeholder text. As for replacing the text with another one this could be done with some jQuery. To do that please try adding the following to the bottom of your theme functions.php (Ideally you’d want to add this to your child theme functions.php or as a mu plugin so you don’t lose it next time you update the theme):

    function replace_search_placeholder_text() { ?>
        <script type="text/javascript">
        jQuery( document ).ready(function() {
            jQuery('#search-wrapper input[type="search"]').attr('placeholder','Some New Text 1');
        });
        </script>
    <?php }
    add_action( 'wp_footer', 'replace_search_placeholder_text' );

    Replace dummy text (Some New Text 1) with what you’d like displayed there 🙂

    Hope this helps 🙂

    Cheers,
    Bojan – WPMU DEV

    Thread Starter vikou1008

    (@vikou1008)

    Hi Bojan,

    Thank you for your help.

    Actually the css to remove the italics didn’t work, and the jQuery to change the input text in the search bar actually crash my website (some syntax error it says). All back to normal now.

    Any other way?

    🙂

    Hey again vikou1008,

    Where exactly are you adding the CSS code? I tested it using Ryu theme by adding the CSS with Simple Custom CSS plugin and everything worked properly, see screenshot http://screencast.com/t/y0nDJ9Ednd6z.

    Can you please keep the CSS code added and post link to your site?

    Since I also tested jQuery in the same theme by placing it to the bottom of the theme functions.php I’m assuming you’re not adding it to the same place? Also since jQuery is working on my end the syntax error probably relates to code not being placed inside php tags so please try adding this instead:

    <?php
    function replace_search_placeholder_text() { ?>
        <script type="text/javascript">
        jQuery( document ).ready(function() {
            jQuery('#search-wrapper input[type="search"]').attr('placeholder','Some New Text 1');
        });
        </script>
    <?php }
    add_action( 'wp_footer', 'replace_search_placeholder_text' );

    If that doesn’t work please let me know where exactly are you adding the code.

    Please let me know 🙂

    Cheers,
    Bojan

    Thread Starter vikou1008

    (@vikou1008)

    Sorry all of this worked to perfection! Thank you.

    The problem before is that instead of copying-pasting your code from here, I selected it from the email I received, which generated errors.

    Thank you very much!

    Oh yes, that usually cause troubles 🙂

    Glad to hear everything is working!

    Have a great day!

    Cheers,
    Bojan – WPMU DEV

    Moderator Kathryn Presner

    (@zoonini)

    Thanks for pitching in, Bojan Radonic!

    vikou1008 – I just wanted to emphasize that if you edited the theme files directly, your tweaks will be overwritten and lost every time you update the theme. A child theme, as Bojan mentioned above, is the recommended way to make changes beyond just CSS to a theme. Here are some guides in case you haven’t made one before:

    http://codex.wordpress.org/Child_Themes
    https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/
    http://op111.net/53/
    http://vimeo.com/39023468

    Keeping your theme up-to-date is important so you’ll get all the latest bug and security fixes, as well as keep the theme compatible with the latest version of WordPress core.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change input text in search bar’ is closed to new replies.