ThemeShaper Forums » Thematic

[closed]

add_filter with get_search_form question

(3 posts)
  • Started 4 years ago by skwasha
  • Latest reply from ryancollier
  • This topic is not resolved
  1. skwasha
    Member

    So, I've started playing with Thematic and was looking at some of the contributed child themes. In the Thematic Featured Site theme, a search form is added to the header. Great! However, when I went to modify the code that is supposedly modifying the search form, the code doesn't actually appear to be called. For example if I replace the input text with something else, I still just get the default text... Also, that <label> tag is never output (this is also true on the demo site for the theme.)

    I'm talking specifically about this:

    // Customize the search form
    function childtheme_search_form($form) {
        $form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
                <label class="hidden" for="s">' . __('Search:') . '</label>
                <div>';
        if (is_search()) {
            $form .='<input type="text" value="' . attribute_escape(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />';
        } else {
            $form .='<input type="text" value="To search us, type and hit enter" name="s" id="s"  onfocus="if(this.value==this.defaultValue)this.value=\'\';" onblur="if(this.value==\'\')this.value=this.defaultValue;"/>';
        }
        $form .= '<input type="submit" id="searchsubmit" value="'.attribute_escape(__('Search')).'" />
                </div>
                </form>';
        return $form;
    }
    add_filter('get_search_form', 'childtheme_search_form');

    Am I missing something here or is this a bug of some sort? Running WP 3.0.1 w/ latest Thematic.

    TIA for any help.

    Posted 4 years ago #
  2. ryancollier
    Member

    Oooh..bump. I have this same problem. It seems that 'get_search_form()' is being called, but the filter isn't working. Anyone?

    Posted 3 years ago #
  3. ryancollier
    Member

    After replacing get_search_form with thematic_search_form this started working.

    //Add Search form to header
    function childtheme_searchform() {
        thematic_search_form();
    }
    add_action('thematic_header','childtheme_searchform',3);
    
    // Customize the search form
    function childtheme_search_form($form) {
        $form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
                <label class="hidden" for="s">' . __('Search:') . '</label>
                <div>';
        if (is_search()) {
            $form .='<input type="text" value="' . attribute_escape(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />';
        } else {
            $form .='<input type="text" value="To search, type and hit enter" name="s" id="s"  onfocus="if(this.value==this.defaultValue)this.value=\'\';" onblur="if(this.value==\'\')this.value=this.defaultValue;"/>';
        }
        $form .= '<input type="submit" id="searchsubmit" value="'.attribute_escape(__('Search')).'" />
                </div>
                </form>';
        return $form;
    
    }
    add_filter('thematic_search_form', 'childtheme_search_form');
    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.