Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have seen many different parameters or arguments that can be passed to a query. For example, category_in, category_and term_id to name a few. Some of these can be found by using print_r to print out the object. ( If I have that right ). Others like the category__in I have been unable to find in codex. Is there a trick to learning about these parameters? How do I find them?

share|improve this question
add comment

4 Answers 4

up vote 2 down vote accepted

They're all in the codex page for WP_Query.

share|improve this answer
    
Thanks Milo. It's funny that doing a direct search in the codex for category__in does not bring up that information –  Jamie Oct 16 '12 at 0:45
add comment

As a compliment to Milo's answer and WP_Query Codex entry above, here is a nice little cheat-sheet and reference which summarizes the $arguments used with WP_Query;

WordPress Query Comprehensive Reference
https://gist.github.com/2023628
Compiled by luetkemj - luetkemj.com

...and here's a little gist to go along with it for debugging your query,

Debugging WP_Query
https://gist.github.com/3699573
from wpsmith

add_action( 'template_redirect', 'wps_debug' );
function wps_debug() {
    global $wp_query;
    if( isset( $_GET['debug'] ) ) {
        echo '<pre>'; print_r( $wp_query ); echo '</pre>';
    }
}

PS. this is just a quick and dirty way to see whats going on. There are other tools, snippets and plugins that do this in a more organized fashion. But that's a discussion for another time.

share|improve this answer
add comment

All of those are in the Codex.

http://codex.wordpress.org/Class_Reference/WP_Query

I feel guilty about posting this as an answer but it does very directly answer your questions, "Is there a trick to learning about these parameters?" and "How do I find them?"

The trick is to search the Codex, and to read the Codex. Follow the links in the Codex. Look in the source code, a link to which is provided in many, but not all, of the Codex entries.

Yes, print_r() helps a lot. var_dump() is better in that it will output information even for empty strings, NULLs, booleans, etc. Its output is harder to read, but you get used to it.

share|improve this answer
    
Why do you feel guilty? –  Jamie Oct 16 '12 at 0:42
2  
Mostly link answers are discouraged. –  s_ha_dum Oct 16 '12 at 4:12
    
@s_ha_dum Shame on you! –  userabuser Oct 16 '12 at 7:37
add comment

The code itself is also a great place to learn about all possible arguments. One advantage over all the other methods (including the Codexs) is that it never gets outdated. Here's the code for WP_Query: http://core.trac.wordpress.org/browser/trunk/wp-includes/query.php

The arguments you are referring to are in its parse_tax_query method.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.