#1435 closed enhancement (fixed)
Pages should be searched
Reported by: | markjaquith | Owned by: | |
---|---|---|---|
Milestone: | 2.5 | Priority: | high |
Severity: | major | Version: | 2.3 |
Component: | General | Keywords: | trac-irrelivent search pages static needs-patch |
Focuses: | Cc: |
Description
Include 'static' pages in search results
Attachments (1)
Change History (28)
#1
@
18 years ago
- Keywords dev-feedback added
- Milestone set to 2.1
There are plugins out there which do this. Do we want it in core?
#2
@
18 years ago
- Cc foolswisdom added
+1 I think it is most people's expectation that pages are searched by default, so I would like to see it in core.
#3
@
18 years ago
Yes, it should. The last time we discussed this, the problem of how to display results with both posts and pages was never solved.
Any implementation is better than no implementation?
#4
@
18 years ago
- Milestone changed from 2.1 to 2.2
I reported this and wrote that patch, but no, I don't agree that any implementation is better than no implementation.
Sticking pages within the post results (interspersed) doesn't seem right.
In fact, any good implementation is going to require theme changes, as right now all we can do is stick the pages into the loop.
Two approaches I see:
A switch to search posts or pages, defaulting to posts. We could make a new template file: page-search.php, and the Default and Classic themes can show our ideal implementation of page search results. Then it would be up to theme authors to create their own implementations.
Unified searching, but using two WP_Query instances. We could run the query made for posts again, searching for pages. $page_search = new WP_Query('foo'); Then in search.php, we would have a second loop. Maybe it could be up at the top, styled differently, only showing titles. Again, it would be up to theme authors to implement that.
It's one of those things where everyone agrees that we should have it, but no one really knows the best way to do it... :-\
2.2 milestone sounds better. We're not even past the idea stage here.
#5
@
18 years ago
Third option:
Search does not discriminate between posts and pages. Instead of sorting by date, it sorts by relevance. This is more like what search engines have trained people to expect.
Sorting by date excludes pages.
#6
@
18 years ago
I like that.
Search algorithms aren't my thing... but doesn't searching by relevance require more than LIKE '%foo%' queries? Are there any GPL projects with advanced searching that we might emulate?
#7
@
18 years ago
If there are fulltext indices on post_content and post_title, you can do a MySQL MATCH() query:
SELECT * FROM wp_posts WHERE MATCH(post_content, post_title) AGAINST('my string to search for');
which returns in order of relevance descending (best first), or to do the same, but also get the relevance (so you can generate 98% match etc):
SELECT p.*, MATCH (post_title, post_content) AGAINST ('My search string') AS score FROM wp_posts AS p WHERE MATCH (post_title, post_content) AGAINST ('My search string');
All this should be valid for MySQL 3.23.23+
More info at:
http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html
#8
@
17 years ago
- Milestone changed from 2.2 to 2.3
This is the 5th highest rated WordPress idea: http://wordpress.org/extend/ideas/topic.php?id=19
#10
follow-up:
↓ 11
@
17 years ago
I don't see why having them in the loop is such a big deal. We put trackbacks and pingbacks in the comments loop. Most themes don't bother to separate them, although they could do it via CSS, since the information is available as part of the comment ($comment_type).
Similarly, if search returns pages in the loop, then the theme can choose whether or not to separate them out based on $post->post_type.
We should not lock themes into doing it only one way. Stick the results in the loop. Themes can determine for themselves whether or not to display it. If you like, make the search default to returning only posts unless there's a "searchpages=true" hidden parameter or something. Again, this leaves it up to the theme (or at least, the search form).
#11
in reply to:
↑ 10
;
follow-up:
↓ 16
@
17 years ago
Replying to Otto42:
I don't see why having them in the loop is such a big deal. We put trackbacks and pingbacks in the comments loop. Most themes don't bother to separate them, although they could do it via CSS, since the information is available as part of the comment ($comment_type).
Putting them in the loop for a search that returns results in date order is bad because they don't have a correct place in that type of ordering as they are by the nature not date related.
Trackbacks and Pingbacks are subtypes of comment - they are just other ways of commenting on a post. A Page is much less similar to a port than that.
I like andys suggestion of search results returning sorted by relevence and then encouraging people to add good search result templates to there themes.
#12
@
17 years ago
Well, then don't limit them to date order either. I like the notion of the relevance order above as well. But optional, of course, as some people won't like that. Perhaps an optional "order=whatever" field to the search form...
More to the point, you're thinking of the Loop as returning a big list of results in a specific order. But the theme can rewind those results and replay them if necessary. If a theme wants to move the Page results to the top, they just write two Loops. The first one only spits out the post_type='page' results, the second one rewinds and then spits out the rest.
#13
@
17 years ago
- Severity changed from critical to major
- Version changed from 1.5.1.1 to 2.3
Bumping this back into contention for inclusion in 2.3 as per the current thread on the mailing list.
There are some great ideas in this ticket thread.
#14
@
17 years ago
If any additional parameters were to be sent with the search term it would make it harder to create pretty URLs of search results.
rob1n has been working on a system allowing for customisation and i18n of all the pretty permalinks bases at ticket #1762 . It would be nice to get this in.
#15
@
17 years ago
Whoops, went a bit off-topic there. What I meant is creating pretty URLs from search results needs to remain a consideration however the searching of pages is implemented.
#16
in reply to:
↑ 11
@
17 years ago
Replying to westi:
Replying to Otto42:
I don't see why having them in the loop is such a big deal. We put trackbacks and pingbacks in the comments loop. Most themes don't bother to separate them, although they could do it via CSS, since the information is available as part of the comment ($comment_type).
Putting them in the loop for a search that returns results in date order is bad because they don't have a correct place in that type of ordering as they are by the nature not date related.
So include them separately somehow. Start with "Undated" and then show "Dated", (kind of like Google's "sponsored results" are separated from regular results). Presumably part of the Theme, but do it this way in the default themes and show people the way :)
No doubt in my mind pages should be included in searches. I hadn't realized there weren't!
#17
@
17 years ago
- Keywords needs-patch added; dev-feedback removed
- Milestone changed from 2.3 (trunk) to 2.4 (future)
#19
follow-up:
↓ 20
@
17 years ago
- Keywords trac-irrelivent added
According to http://codex.wordpress.org/Version_2.4 isnt this alread in core now?
#20
in reply to:
↑ 19
@
17 years ago
Replying to thee17:
According to http://codex.wordpress.org/Version_2.4 isnt this alread in core now?
Ref:
(In [6467]) Throw pages into search queries. Let's see how they handle. see #5149
#22
@
16 years ago
- Cc jidm added
- Milestone changed from 2.5 to 2.7.2
- Resolution fixed deleted
- Status changed from closed to reopened
Hi.
I seriously believe that there should be an option to choose between search on 'any' or 'post'. This could be changed from the admin panel.
In some projects i don't need/want to searh on pages, so i have to manually change 'any' for 'post on:
if ( !isset($q['post_type']) ) { if ( $this->is_search ) $q['post_type'] = 'any'; else $q['post_type'] = 'post';
I think this can't be hard to implement (an option in the backend, a row in wp_options [maybe wp_blogs in case of wpmu] and a modification on the code above to ask for that option).
Please consider implementing this. It has been stuck like this since 2.4 and still is on 2.7.1
Thanks!
Allows searches on pages