0

Stuck on trying call an option variable using the Redux Framework - that is utilizing multi-category select - inside the query. Here's what I have as my query:

$the_query = new WP_Query(array(
array( 'category__and' => $my_options['featured_section']  ),
'posts_per_page' => 1 
)); 
while ( $the_query->have_posts() ) : 
$the_query->the_post();

This doesn't work. The output of $my_options['featured_section'] is:

Array ( [0] => 20 [1] => 16 )

I have two categories selected in the options area, which are ID 20, and ID 16. Any idea why this won't call the correct categories?

6
  • This doesn't "call the categories" at all. It retrieves posts if and only if the are assigned to both categories. Is that what you want?
    – s_ha_dum
    Commented Mar 16, 2014 at 17:20
  • Should I be using: 'cat' => $my_options['featured_section'] Yes, I'm looking to retrieve posts that are within the selected categories. Commented Mar 16, 2014 at 17:32
  • To retrieve posts in both categories-- not in one or the other or both, but absolutely both-- your code is correct, and using cat would be wrong. If that is not the result you see something is interfering, maybe a filter, but I can't guess what.
    – s_ha_dum
    Commented Mar 16, 2014 at 17:42
  • Yea, I'm not sure, I don't believe there is a filter. Here is what I was told by the Redux developer, yet I'm still not grasping it, unfortunately: "Umm, use the data attribute for the select field and fill args. Like this: 'data' => 'category', 'args' => array('cat' => $my_options['featured_section']) But as you say I should be using 'category__and' as well... Commented Mar 16, 2014 at 17:49
  • Their code suggests that $my_options['featured_section'] is not an array but a comma separated string, which conflicts with what you've said.
    – s_ha_dum
    Commented Mar 16, 2014 at 18:14

1 Answer 1

1

I'm Kevin, one of the devs at Redux. I'd be happy to take a look at your situation more closely if I could get you to hope on over to our github page and submit your issue via our issue tracker https://github.com/ReduxFramework/redux-framework. Please be sure to include the version of Redux you are using (important as we might have a newer version) and a sample of your config, specifically the section you are attempting to use here.

Thanks!

1
  • Hi Kevin, Thanks for your post! I'm working with Redux, migrating from SMOF, and I understand most every use except the multi selection for categories. I posted at the issue tracker and received a helpful response but am still stuck. If I don't use the "multi" option (or have it set to false) the query pulls the correct category, but if I have "multi" set to true, the output doesn't work within the query. Here's the post at the issues tracker that I was offered some help but still failed to grasp :) github.com/ReduxFramework/redux-framework/issues/909 Commented Mar 19, 2014 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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