Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#9103 closed defect (bug) (fixed)

Put search string into <title> of search results page

Reported by: jidanni's profile jidanni Owned by: westi's profile westi
Milestone: 2.8 Priority: lowest
Severity: trivial Version: 2.7
Component: Template Keywords: has-patch needs-testing
Focuses: Cc:

Description (last modified by westi)

WordPress (or at least its default theme) should consider putting the
search string into the XHTML <title> of the search results page.

The goal is to make different searches findable in one's browser
history, etc.
Consider this MediaWiki example:
http://en.wikipedia.org/wiki/Special:Search?search=jidanni
gives

<title>jidanni - Search results - Wikipedia, the free encyclopedia</title>

(Of course one should properly escape the search string, to prevent
XSS.)

Attachments (1)

9103.diff (733 bytes) - added by DD32 16 years ago.

Download all attachments as: .zip

Change History (9)

#1 @jidanni
16 years ago

Same with Google, http://www.google.com/search?q=movie+ideas gives

<title>movie ideas - Google Search</title>

@DD32
16 years ago

#2 @DD32
16 years ago

  • Keywords has-patch needs-testing added
  • Milestone set to 2.8

Not too sure on the translation front, The other option is:

$title = __('Search Results') . $t_sep . wp_specialchars($search);

#3 @DD32
16 years ago

  • Component changed from Themes to Template
  • Owner set to anonymous

#4 @jidanni
16 years ago

Also note the search string should be to the very left, as Google and MediaWiki do, or else there is little chance it will be visible in a browser tab, thus all search result tabs will just look the same.

Also consider taking the string produced for the <title> and reusing it in <h2>.

#5 @DD32
16 years ago

Also note the search string should be to the very left

WordPress includes a option for Right to Left, or Left to right ordering of the title options.

By default, It'll be Blog Title => Major => Minor (minor being the tag, or the search term), If you pass 'right' to 3rd param, It'll be Minor => Major => Blog Title

I dont think the default theme shows the search term.. I know my custom one does, So it completely skiped my mind.

#6 follow-up: @jidanni
16 years ago

I believe I'm trying to say: instead of your diff's

$title = sprintf(__('Search Results %s %s'), $t_sep, wp_specialchars($search));

You should do

$title = sprintf(__('%s %s Search Results'), wp_specialchars($search), $t_sep,);

As Google and Wikipedia do. Else you will have munched 75% of each tab
with "Search Results". Better still would be

$title = sprintf(__('%s %s Search'), wp_specialchars($search), $t_sep,);

Mine are for a totally "leftist" solution.
It seems your original should also be retained, to provide for an additional totally "rightest" choice.

#7 in reply to: ↑ 6 @westi
16 years ago

  • Cc westi added
  • Description modified (diff)
  • Owner changed from anonymous to westi
  • Status changed from new to assigned

Replying to jidanni:

I believe I'm trying to say: instead of your diff's

$title = sprintf(__('Search Results %s %s'), $t_sep, wp_specialchars($search));

You should do

$title = sprintf(__('%s %s Search Results'), wp_specialchars($search), $t_sep,);

As Google and Wikipedia do. Else you will have munched 75% of each tab
with "Search Results". Better still would be

$title = sprintf(__('%s %s Search'), wp_specialchars($search), $t_sep,);

Mine are for a totally "leftist" solution.
It seems your original should also be retained, to provide for an additional totally "rightest" choice.

Nope the diffs are correct.

WordPress is by default leftist.

If you want rightist you call wp_title in your theme with the third argument as 'right' and it flips them all round for you.

This is exactly how the default and classic themes do it.

#8 @westi
16 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [10660]) Put search string into <title> of search results page. Fixes #9103 props DD32.

Note: See TracTickets for help on using tickets.