Skip to main content
15 events
when toggle format what by license comment
Feb 1, 2013 at 13:20 comment added Chief Alchemist As a side note...to anyone reading this...please comment your code. You never know who else might have to work on it. A simple "this query's args are augmented with function: xyz() in functions.php" would have saved me a load time. 10 secs might save someone - including yourself - hours.
Jan 31, 2013 at 10:02 comment added Simon You're welcome @Chief Alchemist. pre_get_postswas the right candidate for that behavior.
Jan 31, 2013 at 1:01 comment added Chief Alchemist and @Andy Killen. Thanks too for your help / nudge.
Jan 31, 2013 at 1:01 comment added Chief Alchemist Hey @Simon - Thanks for the nudge / push. I finally tracked down an add_action( 'pre_get_posts', 'function_to_modify_the_query_in_category_php'). Yup, that function was augmenting the standard query parms. Why there was also code in the category.php I'm not sure. Obviously, I got distracted. That said, it still doesn't explain why 'cat'=> $var made things wonky. Hard coded value ok, $var not ok. That's still pretty odd in my book in a feels like a bug sorta way. But then again, I n00bed this one up pretty good, eh? Thanks again for your help.
Jan 31, 2013 at 0:01 comment added Chief Alchemist btw, turns out the "not" hack doesn't quite work either. The next_posts_link() displays on the last page. Which leads me to believe that's using a different set of args than I'm submitting with my "not cats" string and other args. Now I'm stuck and stumped.
Jan 30, 2013 at 23:53 comment added Chief Alchemist Thx again @Simon. I wish it was as easy as switching themes but this has to do with additional custom post types and such that are build into this custom theme. I spec a query. I make the request. WP use a different set of args. Even if that's another plugin, etc. that's still a bug (to me). It doesn't make sense to allow plugins, etc. and then have no way of knowing which one is accountable for "rejecting" the request and swapping in its own. That doesn't leave much faith in WP_Query, yes? Further more...'cat'=> -1,-3,-4 works but 'cat'=> 2 does not. That too strikes me as a bug, no? :(
Jan 30, 2013 at 21:49 comment added Simon Maybe try to switch theme just to check the behavior and consistency of the returned results. As it's working for me and another guy here, I would suppose there's no bug in core, but some other hook in the theme or a plugin.
Jan 30, 2013 at 21:33 comment added Chief Alchemist Thanks again @Simon. I suspect there's some sort of add "leak" elsewhere in the theme. I didn't do the build, I'm just in charge of enhancements. But even so, this is a WP core bug IMHO. I should either we an error / it should bomb, or I should get the results based on the query args. As it is I'm getting a random query when there is a particular (but legit) condition (i.e., 'cat' => $var). Question: Getting the WP bug fixed soon is unlikely, so how about troubleshooting / finding a work around? Any thoughts? Thanks again.
Jan 30, 2013 at 21:11 comment added Simon I checked your original code in a category.php page and it's working properly. No mess in post_type or post_per_page.
Jan 30, 2013 at 20:59 comment added Simon Ok, this should work only on a single page, not category page, sorry I missed that ! It's interesting, but there is probably an explaination to your problem.
Jan 30, 2013 at 20:23 comment added Chief Alchemist Well...I had added the global $post; myself the first time and still pulled the error. I guess that's why I was asking. Strange, right?
Jan 30, 2013 at 16:06 comment added Simon I add the global $post, i guess this is what throws the parse error, sorry. I did not notice on my tests anything wrong except the empty $category_id. Just a note, I don't use print_r which is difficult to read, I use the console plugin which allow you to see variables in the firebug console. It's very handy and makes reading much easier
Jan 30, 2013 at 16:01 history edited Simon CC BY-SA 3.0
added 17 characters in body
Jan 30, 2013 at 15:44 comment added Chief Alchemist Thx @Simon. Allow me to clarify a bit. The 'cat' => $var does work (kinda). I shows up in the query_var. However, when using a $var to do that assignment, other things go wonky (e.g. posts_per_page, post_type, etc.). I'm not getting an error. What's happening is the arg array I us in WP_Query() doesn't match what I see in the print_r() *when I try to assign 'cat' => with a $var. Yeah, wrap your head around that :) Also, I'm trying to use the line of code you mention and I'm pulling: Parse error: syntax error, unexpected '[' . ??
Jan 30, 2013 at 15:05 history answered Simon CC BY-SA 3.0