ThemeShaper Forums » Thematic

[closed]

Search.php - Change "Search Results For" heading

(5 posts)
  • Started 4 years ago by BAC
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. BAC
    Member

    Hi,

    I have been digging about Thematic trying to find the function that outputs the text of the heading above the search results.

    i.e.
    search results for: my search terms

    I would like to change this to

    to
    X results for: my search terms (0.33 seconds)

    Ideally I want to use a filter in functions.php

    The following code correctly returns the results count and search execution time.


    <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(''); echo $count . ' '; _e('results'); wp_reset_query(); ?>


    <?php timer_stop(1); ?> seconds)

    Does anyone know the best way of achieving this?

    This is a nice little enhancement that I am sure others might be interested in.

    Thanks for any help on this.

    BAC

    Posted 4 years ago #
  2. iCristiano
    Member

    Any help with filtering the "Search Results For" heading??

    Posted 3 years ago #
  3. this seems to be generated by the thematic_page_title() function in content-extensions.php

    i believe you'd need to filter it:

    function change_search($content){
            if (is_search()) {
    		$content .= '<h1 class="page-title">';
    		$content .= __('I Found Your Bacon:', 'thematic'); //used to say Search Results For:
    		$content .= ' <span id="search-terms">';
    		$content .= esc_html(stripslashes($_GET['s']));
    		$content .= '</span></h1>';
    	}
    }
    add_filter('thematic_page_title','change_search');
    Posted 3 years ago #
  4. sumansinha
    Member

    @helgatheviking: You missed the return. Also the first $content .=... statement is better written as $content =... if you want to replace the default 'Search Results For'. But thanks a bunch for pointing me in the right direction! :)

    Those minor corrections below, if I may... :)

    function change_search_title($content) {
    if (is_search()) {
    		$content = '<h1 class="page-title">';
    		$content .= __('I Found Your Bacon:', 'thematic'); //used to say Search Results For:
    		$content .= ' <span id="search-terms">';
    		$content .= esc_html(stripslashes($_GET['s']));
    		$content .= '</span></h1>';
    }
    return $content;
    }
    add_filter( 'thematic_page_title', 'change_search_title' );
    Posted 3 years ago #
  5. good catch sumansinha.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.