• Resolved indietrash

    (@indietrash)


    hi,

    I want my search box to say “search for…”. as in, I want the default input of the seach box to be “search for…”, so that people see that it’s a search box – not just a weird box. could anyone help me with this? I have basically no knowledge of php myself. =/ here is my php:

    <?php
    get_header();
    ?>

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>

    <div id=”small”><smallbg><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></smallbg></div>

    <h2>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></h2>

    <div class=”entry”>
    <?php the_content(‘Read the rest of this entry »’); ?>
    </div>

    <p class=”postmetadata”><i><?php the_tags(‘Tags: ‘, ‘, ‘, ‘
    ‘); ?></i>Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ ‘); ?> </p>
    </div>

    <?php endwhile; ?>

    <div class=”navigation”>
    <div class=”alignleft”><?php next_posts_link(‘« Older Entries’) ?></div>
    <div class=”alignright”><?php previous_posts_link(‘Newer Entries »’) ?></div>
    </div>

    <?php else : ?>

    <h2 class=”center”>Not Found</h2>
    <p class=”center”>Sorry, but you are looking for something that isn’t here.</p>
    <?php get_search_form(); ?>

    <?php endif; ?>

    <?php get_footer(); ?>

Viewing 15 replies - 1 through 15 (of 22 total)
  • Thread Starter indietrash

    (@indietrash)

    I mistakenly put this as “resolved”. it’s *not*. so help me still. ??

    I looked at this:
    https://bavotasan.com/tutorials/getting-text-in-your-wordpress-search-box/

    but I don’t have a searchform.php. =/

    What theme are you working with? Or better, a link to your site if possible.

    Thread Starter indietrash

    (@indietrash)

    hi.

    I found that it’s in functions.php. that looks like this:

    <?php

    if (function_exists(“register_sidebar”)) {
    register_sidebar(Array(“name” => “sidebar”));
    register_sidebar(Array(“name” => “sidebar2”));
    }

    // custom widgets

    function widget_yes_search() {
    ?>
    <?php _e(‘Search’); ?>
    <form id=”searchform” method=”get” action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>”>
    <div>
    <input type=”text” name=”s” id=”s” size=”15″ />
    <? /*<input type=”submit” value=”<?php _e(‘Search’); ?>” />*/?>
    </div>
    </form>
    <?php
    }
    if ( function_exists(‘register_sidebar_widget’) )
    register_sidebar_widget(__(‘Search’), ‘widget_yes_search’);

    ?>

    Thread Starter indietrash

    (@indietrash)

    I tried adding value=”Search & Hit Enter” in <input type=”text” name=”s” id=”s” size=”15″ />, and the lines:

    onfocus=”if (this.value == ‘Search & Hit Enter’) {this.value = ”;}”
    onblur=”if (this.value == ”) {this.value = ‘Search & Hit Enter’;}” />

    however this was to no avail. didn’t work at all.

    Just a hint: if you don’t have searchform.php in your template, WordPress will go ahead and grab searchform.php from the default theme.

    So go ahead and copy the searchform.php from the default theme into your theme folder, and then edit the <input id=”s” …. value=”value here”> and add onclick=”value=””

    I know this is off the topic, but is this…

    <form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>

    …prone in any way to encourage XSS vulnerabilities, or is it being expressed in such a way as to avoid those possible issues? Just curious.

    Thread Starter indietrash

    (@indietrash)

    althalos: there is no searchform.php in default or classic either! it seems like it’s moved to function.php.

    Thread Starter indietrash

    (@indietrash)

    althalos: I tried adding what you wrote to the function.php (see the post two posts above yours), but nothing changed.

    Would that be “search.php” ? Rather than searchform.php?

    “Different WordPress Themes feature different template files. Some include a search.php template file. This is not a Search Page, it is merely a template that displays the search results. There is also a template file called searchform.php. This is a template file that is often included in the sidebar of many themes and generates the search box form. If there isn’t one in your theme, you can easily copy it from the Default theme.”

    https://codex.www.ads-software.com/Creating_a_Search_Page

    Thread Starter indietrash

    (@indietrash)

    no. search.php is the results, not the form. the form seems to be in function.php.

    see what I just added above.

    Okay. I’m as confused as you now, indietrash. I just went all the way back to an archive of 2.8.1, and I still don’t see searchform.php in the default theme. Time for some research.

    From “general-template.php” 2.8.4;

    * Display search form.
    *
    * Will first attempt to locate the searchform.php file in either the child or
    * the parent, then load it. If it doesn’t exist, then the default search form
    * will be displayed. The default search form is HTML, which will be displayed.
    * There is a filter applied to the search form HTML in order to edit or replace
    * it. The filter is ‘get_search_form’.
    *
    * This function is primarily used by themes which want to hardcode the search
    * form into the sidebar and also by the search widget in WordPress.
    *
    * There is also an action that is called whenever the function is run called,
    * ‘get_search_form’. This can be useful for outputting JavaScript that the
    * search relies on or various formatting that applies to the beginning of the
    * search. To give a few examples of what it can be used for.
    *
    * @since 2.7.0

    Probable well informed solution:

    https://www.ads-software.com/support/topic/249694?replies=7#post-1032879

    Thread Starter indietrash

    (@indietrash)

    I tried creating a searchform.php in both default and my current theme, but it didn’t do anything. I put this in it:

    <div class=”search”>
    <form method=”get” class=”search-form” id=”search-form” action=”<?php bloginfo( ‘home’ ); ?>/”>
    <div>
    <input class=”search-text” type=”text” name=”s” id=”search-text” value=”Search this site” />
    <input class=”search-submit” type=”submit” name=”submit” id=”search-submit” value=”Search” />
    </div>
    </form>
    </div>

    but as I’ve stated some posts above, the search form seems to be in function.php.

    I would like to look at the theme if it is freely available. Can you tell me the theme name? Or is it all custom?

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘editing my search box’ is closed to new replies.