Get the most repeated post contents from a search?

In my site the posts content is always the name of a school, so if I search for Chicago I get a lot of posts with different schools as content. What I want to do is to get the Schools with the most posts, so I could display this somewhere:

School A - 4
School B - 3
School C - 2
School D - 2

(The number at the right is the number of posts the school has)

Read More

So what I need to get the most repeated post contents from a particular search including the ones that don’t appear in first results page.

I don’t know how complicated it can be so if there is no simple way I would be very grateful for just being pointed towards the right direction, so I later figure out how to do it. My site is made with wordpress and the posts are on a SQL database. Please ask if it’s not clear or for any more info.

Thanks

Related posts

Leave a Reply

1 comment

  1. The problem with your approach is that post’s content pretty much ignored in WordPress query architecture. It is meant to be textual information, as opposed to technical meta information.

    You have several options:

    1. Try to modify raw SQL of query request through filters, such as posts_where.

    2. Assign school name to custom field and use custom fields parameters in query (much enhanced in upcoming 3.1 version of WP).

    3. As per hakre’s suggestion create custom taxonomy and assign schools to posts as its terms.