Title: Problem with multiple categories
Last modified: May 23, 2017

---

# Problem with multiple categories

 *  Resolved [iuliasro](https://wordpress.org/support/users/iuliasro/)
 * (@iuliasro)
 * [9 years ago](https://wordpress.org/support/topic/problem-with-multiple-categories/)
 * I’ve found a problem when the args array is created and the categories are added.
   Line 391:
    ‘cat’ => array( ‘cat’ => $category)
 * it should be
 * ‘cat’ => $category
 * The posts were not correctly pulled from the active posts categories.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Daniel Floeter](https://wordpress.org/support/users/kometschuh/)
 * (@kometschuh)
 * [9 years ago](https://wordpress.org/support/topic/problem-with-multiple-categories/#post-9160845)
 * Hello Iuliasro,
 * can you write me in more details what you do.
    And what your problem is?
 * Because I have no problems and can’t comprehend your issue.
    I do like it is 
   described here: [https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters](https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters)
 * – How many categories have you assigned to one post?
    – How many categories do
   you have? – Which PHP version do you use (on the server)? – Which WordPress version
   do you use? – (Can you write me your Theme name?)
    -  This reply was modified 9 years ago by [Daniel Floeter](https://wordpress.org/support/users/kometschuh/).
 *  Thread Starter [iuliasro](https://wordpress.org/support/users/iuliasro/)
 * (@iuliasro)
 * [9 years ago](https://wordpress.org/support/topic/problem-with-multiple-categories/#post-9162673)
 * Hi,
 * Sorry for not giving more details.
    The args should be:
 * $query = new WP_Query( array( ‘cat’ => 4 ) );
 * but they are in your code:
 * $query = new WP_Query(array(‘cat’ => array( ‘cat’ => 4 ) ));
    this is the exact
   copy from your code:
 * $args = array(
    ‘cat’ => array( ‘cat’ => $category), ‘category__not_in’ => $exclude_categories,‘
   post__not_in’ => array( $exclude_current_post ), ‘showposts’ => isset($instance[‘
   num’])?$instance[‘num’]:0, // Number of same posts that will be shown ‘ignore_sticky_posts’
   => 1, ‘orderby’ => $sort_by, ‘order’ => $sort_order );
 * The problem was that the posts were not pulled from the same category, the category
   was ignored. I corrected that line and now the posts are pulled from the correct
   category. It is a small problem probably from your latest update and I just wanted
   to warn you about it.
 * I have a custom theme, wordpress 4.2.2
 * Thank you for your response.
 *  Plugin Author [Daniel Floeter](https://wordpress.org/support/users/kometschuh/)
 * (@kometschuh)
 * [9 years ago](https://wordpress.org/support/topic/problem-with-multiple-categories/#post-9165398)
 * Hello Iuliasro,
 * I found a bug and fix it on GitHub: [https://github.com/DanielFloeter/same-category-posts](https://github.com/DanielFloeter/same-category-posts)
 * Are you familair with GitHub? Because you can download the code there ([https://github.com/DanielFloeter/same-category-posts](https://github.com/DanielFloeter/same-category-posts))
   and copy the files to your plugin folder ([your-wp-installation]/wp-content/plugins/
   same-category-posts) to your wordpress installation or upload the downloaded 
   ZIP file with WordPress (Dashboard > Plugins > Installed Plugins > “Add New” 
   button > “Upload Plugin” button >)
 * Can you give me a short feedback, if the code works for you?
 * Greetings
    Daniel

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem with multiple categories’ is closed to new replies.

 * ![](https://ps.w.org/same-category-posts/assets/icon-256x256.png?rev=1419009)
 * [Same Category Posts](https://wordpress.org/plugins/same-category-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/same-category-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/same-category-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/same-category-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/same-category-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/same-category-posts/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Daniel Floeter](https://wordpress.org/support/users/kometschuh/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/problem-with-multiple-categories/#post-9165398)
 * Status: resolved