How do I read values (PHP defined constants) from wp-config.php?

后端 未结 7 1015
悲哀的现实
悲哀的现实 2021-02-07 03:40

I need to get username, password etc from the wp-config file to connect to a custom PDO database.

Currently I have another file where I have this info, but

7条回答
  •  隐瞒了意图╮
    2021-02-07 04:25

    I have even defined my own constants in in wp-config.php and managed to retrieve them in theme without any includes.

    wp-config.php

    define('DEFAULT_ACCESS', 'employee');
    

    functions.php

    echo "DEFAULT_ACCESS :".DEFAULT_ACCESS;
    

    outputs DEFAULT_ACCESS :employee

提交回复
热议问题