In my theme I have a custom search template, search.php ..
I have some code to run a query of custom field values in some custom posts. They are classified ads, these custom posts, and the custom fields are things like 'make', 'model', 'year', 'color', etc. I want to allow people to be able to search by make, model, year, color, price, etc.
So it is a straight-forward query_posts of the arguments of 'post_type', 'paged', and then the custom field queries in a 'meta_query' array:
The problems I am having are this:
- using any more than exactly 8 of those key-value pair arrays in the meta_query array causes my search to query and query endlessly and never (or at least as long as I was willing to wait) return a page, not even a 404 not found WP page. If I use 8 or less of those key-value pair arrays within the meta_query array, I'm okay, I get a search results page from WP.
So the question here is, why is there a limit? Is there a limit? Or am I just doing something wrong?
- the next problem I am having is that after experimenting with the above code, maybe an hour or several later, my site crashes, telling me:
"Warning: mysql_connect() [function.mysql-connect]: User vg_blog already has more than 'max_user_connections' active connections in /home/vg/public_html/wp-includes/wp-db.php on line 1034
Error establishing a database connection"
.. which thankfully I know how to resolve through my web host (they raise the limit of max connections) .. and I am lead to believe that my meta_query array is causing this. My bad query_posts code is not only not returning search results, it is also crashing my database!
So, I am wondering ... anyone can help me figure out the right way to do this search of the custom fields?