Hot answers tagged

1

You need to setup multiple meta_queries using an array. Since you didn't have a value you were looking for I'm just making sure that thePrice and thePrice2 are not blank. I set each meta query to a variable and then used them in the main orderby statement with a space between them. I wasn't able to do any testing on the code so if you have issues let me know....


1

This is how meta_key/_values work. How you store your values is case sensitive. Example meta_key = 'foo' and meta_value = 'Bar' Would return the result you are looking for: $posts = new WP_Query( 'post_type=post&meta_key=foo&meta_value=Bar' ); Would not return the result you are looking for: $posts = new WP_Query( 'post_type=post&meta_key=...


1

You can just run through the loop and set a flag: if ( $query->have_posts() ) : $any_in_cat = false; while ( $query->have_posts() ) : $query->the_post(); if ( in_category( 'first-major' ) ) : $any_in_cat = true; endif; endwhile; $query->rewind_posts(); /* if $any_in_cat == true at this point then ...


1

You can create a separate function to check your array of posts contains a post with that category. It will basically do what you are now but it will allow you to call the function once instead of each time through the loop. You would put this code in your functions.php file: function does_array_contain_category( $categories, $posts ){ foreach( $posts ...



Only top voted, non community-wiki answers of a minimum length are eligible