You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP7升级致WordPress Taxonomy Order插件失效,求解决方案

Fixing the count() Warning in the Discontinued Taxonomy Order Plugin

Hey there, let's get that PHP warning sorted out. The issue here is that PHP 7.2 and later enforces stricter rules for the count() function — it only accepts arrays or objects that implement the Countable interface. The old Taxonomy Order plugin's code on line 280 is passing a non-countable value (like null or a scalar) into count(), which triggers the warning.

Here's how to fix it step by step:

  • First, locate the taxonomy-order.php file in your plugins directory, then jump to line 280. You'll likely see a line that looks something like this:

    $term_count = count($some_variable);
    

    (The variable name might be different, like $terms or $items — focus on the count() call here.)

  • Replace that line with a conditional check to ensure we only call count() on countable values. If your server runs PHP 7.3 or newer, use the is_countable() function for cleaner code:

    $term_count = is_countable($some_variable) ? count($some_variable) : 0;
    
  • If you're stuck on an older PHP version (pre-7.3), use this more compatible check that verifies the value is either an array or a Countable object:

    $term_count = (is_array($some_variable) || $some_variable instanceof Countable) ? count($some_variable) : 0;
    
  • Save the file, then refresh your site to confirm the warning is gone.

A quick note: Always make a backup of the plugin file before modifying it — just in case you need to revert changes later. Since the plugin is discontinued, you don't have to worry about updates overwriting your fix.

内容的提问来源于stack exchange,提问作者lukehillonline

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:33:46