WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

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.


share|improve this question
You say the "school" is the post content. How can post content have posts? – onetrickpony Dec 19 '10 at 11:10
Can you perhaps provide a bare-bones example of what a given post's content may look like? Can each post make references to several schools or just one? – t31os Dec 19 '10 at 13:36
The content is just the name of a single school/university or idk institute. – Lisandro Dec 25 '10 at 19:40
@Lisandro: I think you should make use of custom taxonomies (Wordpress Codex). Then you can associate a specific school to an article and list / search / weight / rate based on that. – hakre Feb 6 '11 at 16:55

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.