6

I have recently come across a problem where i can't assign products to categories as the categories aren't displaying in the meta box when adding products. Here is the example:

Once i add the new category it seems to disappear when the page is reloaded. You can see that it says 6 items but it doesn't show any categories. Here is an example:

max
  • 89
  • 2
  • 8
  • make sure you haven't add same slug for other custom taxonomy, also check if any plugin create the issue., – dipmala Aug 22 '18 at 11:28
  • @dipmala thanks for the comment. i have looked at other categories and there all doing the same. I haven't added a new plugin or updated for a while and this has just happened. – max Aug 22 '18 at 11:48
  • it looks like you are having a conflict somewhere. Try switching to one of the default WordPress themes [IE: 2017] and see if the issue is still there. If it is, Try deactivating all your other plugins except Woocommerce and see if the problem goes away. If it does activate the plugins 1 by 1 till you find the culprit. I would make a proper backup of the site first just in case BTW! [duplicator plugin is really good, it preserves everything perfectly and puts the site into an easy to use .zip file] – Moose Aug 23 '18 at 14:02

3 Answers3

3

OP created a Wisdom of the Ancients post for me with this one.

I turned on debugging and saw an error discussed in this question: How to resolve "ORDER BY clause is not in SELECT list" caused MySQL 5.7 with SELECT DISTINCT and ORDER BY. I was using a Managed MySQL service from Digital Ocean and couldn't modify the global settings or my.cnf files.

For my future self and other wanderers. My issue was that MySQL's 'ANSI' mode includes 'ONLY_FULL_GROUP_BY'.

WordPress filters out 'ONLY_FULL_GROUP_BY' by default in /wp-includes/wp-db.php but my Managed SQL server had ANSI set by default as well.

My solution was to make a crappy little WordPress plugin that would make sure they both got removed every session. https://fishy.getgit.co/fishy/remove-ansi-sql-mode

Or just Copy/Pasta:

<?php
/*
Plugin Name: Remove ANSI SQL_MODE
Version: 1.0
Description: Removes the 'ANSI' SQL MODE if it exists as it contains 'ONLY_FULL_GROUP_BY' since MySQL 5.7.5. See https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_ansi
*/
class Remove_Ansi_Sql_Mode {
    static function init(){
        add_action('init', array( __CLASS__, 'strip_ansi_mode' ) );
    }

    static function strip_ansi_mode(){
        global $wpdb;
        // Copied from /wp-includes/wp-db.php
        $incompatible_modes = array(
          'NO_ZERO_DATE',
          'ONLY_FULL_GROUP_BY',
          'STRICT_TRANS_TABLES',
          'STRICT_ALL_TABLES',
          'TRADITIONAL',
          'ANSI' // Adding ANSI
        );
        $sql_modes = explode(',', $wpdb->get_col( "SELECT @@SESSION.sql_mode" )[0]);
        foreach ($sql_modes as $key => $value) {
          if(in_array($value, $incompatible_modes)){
            unset($sql_modes[$key]);
          }
        }
        $wpdb->set_sql_mode($sql_modes);
    }   

}
Remove_Ansi_Sql_Mode::init();
Richard Cagle
  • 158
  • 1
  • 11
2

I had this same issue after updating to WooCommerce 3.6. Solved it by deactivating the WP Term Images plugin.

Zade
  • 692
  • 8
  • 28
1

Try this, it's working for you

Show Product Categories screenshot

Priyanka Modi
  • 1,594
  • 1
  • 8
  • 14
  • thanks for the comment. The problem is my menus aren't displaying either. Strange – max Aug 22 '18 at 13:25
  • Sorry I don't understand. I have a child theme if this helps. Please explain what you mean. – max Aug 22 '18 at 14:02