My contribution to WordPress is finally in there. It all goes back to when we started this project from our client Buzz-Media. We had a pretty complicated problem dealing with types of data, to which the newest feature of WordPress in 3.0 (custom post types) was the logical answer.
The problem broke down to basically this. When you query posts using something similar to:
get_posts(array('post_type' => array('book', 'newspaper-article', 'paper')));
you can specify an array of ‘post_types’ that can be searched through. Thus, if you know, for instance, that the name of the entry contains the word ‘dog’ but you do not know if it is a ‘book’, ‘newpaper-article’, or a ‘paper’, then you would normally call something like:
get_posts(array('post_type' => array('book', 'newspaper-article', 'paper'),'s' => 'dog'));
What I found was that you could not specify this via the url with a query string. Typically, with WordPress, you can specify a url like the following and it will work:
however, if you need to specify that you think it is either a book or a newspaper-article, you would think that the url should be structured similar to this:
(the latter because often times WordPress accepts arguments in comma delimited format), but neither actually work in 3.0. This, in my opinion, is wrong, since:
- if you omit the post_type query var, WordPress by default checks all post_types for that named post
- you can specify an array in the params sent to both
- this was the newest feature of 3.0, and thus should have the flexibility built right in
As it turns out, the creators of WordPress agreed with me, and asked for a solution to the problem, if I was willing to offer one. Luckily, I had already created a solution, and I submitted it for their approval. After several corrections to code structure (to be in compliance with their coding standards), it was accepted and slotted to be released with WP 3.1, and it was. Also, my change incited additional, similar bug fixes in the same file/function as this one.
I am proud to announce that I am officially a contributor to WordPress Core, not just tons of plugins.