最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

filters - Call to undefined function error after adding add_filter to wp-config

programmeradmin2浏览0评论

I am getting

Fatal error: Call to undefined function add_filter() in example/wp-config.php on line 20

after adding

add_filter( 'auto_update_plugin', '__return_true' );

to wp-config.php

My plugins.php file is present and add_filter() is defined inside of it.

I just want to enable automatic updates for core, plugins and thems.

What am I doing wrong?

I am getting

Fatal error: Call to undefined function add_filter() in example/wp-config.php on line 20

after adding

add_filter( 'auto_update_plugin', '__return_true' );

to wp-config.php

My plugins.php file is present and add_filter() is defined inside of it.

I just want to enable automatic updates for core, plugins and thems.

What am I doing wrong?

Share Improve this question asked Apr 21, 2014 at 22:13 SkyHiRiderSkyHiRider 1731 gold badge2 silver badges7 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 4

There is a section that should look like this:

defined( 'ABSPATH' ) || define( 'ABSPATH', __DIR__ . '/' );
require_once( ABSPATH . 'wp-settings.php' );

add_filter() is available after that, you are probably using it too early.

The recommended best practice is to use a mu-plugin for this. Adding add_filter()s to wp-config.php directly can cause all kinds of other problems and conflicts.

I used wp-cli and got this error.

I had in wp-config.php at bottom:

remove_filter('template_redirect','redirect_canonical');

instead i put to top

define('WP_HOME','http://example');

define('WP_SITEURL','http://example');

it solved my problem

发布评论

评论列表(0)

  1. 暂无评论