gpt4 book ai didi

wordpress - 添加产品时 Woocommerce 产品类别丢失(未显示)

转载 作者:行者123 更新时间:2023-12-02 07:04:30 30 4
gpt4 key购买 nike

我最近遇到一个问题,我无法将产品分配给类别,因为添加产品时类别没有显示在元框中。这是示例:

一旦我添加新类别,重新加载页面时它似乎就会消失。您可以看到它显示了 6 个项目,但没有显示任何类别。这是一个示例:

最佳答案

OP 创建了 Wisdom of the Ancients为我发布这个。

我打开调试并看到此问题中讨论的错误: How to resolve "ORDER BY clause is not in SELECT list" caused MySQL 5.7 with SELECT DISTINCT and ORDER BY 。我使用的是 Digital Ocean 的托管 MySQL 服务,无法修改全局设置或 my.cnf 文件。

为了 future 的自己和其他流浪者。我的问题是 MySQL 的 ' ANSI ' 模式包括 'ONLY_FULL_GROUP_BY'。

WordPress 默认在 /wp-includes/wp-db.php 中过滤掉“ONLY_FULL_GROUP_BY”,但我的托管 SQL 服务器默认也设置了 ANSI

我的解决方案是制作一个蹩脚的小 WordPress 插件,以确保它们在每个 session 中都被删除。 https://fishy.getgit.co/fishy/remove-ansi-sql-mode

或者只是复制/面食:

<?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();

关于wordpress - 添加产品时 Woocommerce 产品类别丢失(未显示),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51965839/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com