How to create custom variables in the wp-config

I would like to add some custom config variables in the wp-config.php file (not in the functions.php). Then, I need to a

I would like to add some custom config variables in the wp-config.php file (not in the functions.php). Then, I need to access to these variables in my templates.
What is the way to do that ?

I would like to add some custom config variables in the wp-config.php file (not in the functions.php). Then, I need to access to these variables in my templates.
What is the way to do that ?

Share Improve this question edited Mar 2, 2020 at 13:10 SherylHohman 8419 silver badges14 bronze badges asked Aug 13, 2013 at 13:14 miko7358miko7358 4062 gold badges7 silver badges18 bronze badges 3
  • Hi can you get answer of this question. please i need this functionality. thank you – Renish Khunt Commented Apr 21, 2014 at 6:53
  • I accepted the following answer, just add your custom variable with a define – miko7358 Commented Apr 22, 2014 at 9:34
  • Just FYI these are more accurately "defined constants" and not "variables". – Jesse Nickles Commented Oct 13, 2020 at 10:07
Add a comment  | 

1 Answer 1

Reset to default 16

Why do you need this?

In wp-config you can set defines. They will be accesible everywhere without needing to use globals. Define something: define('MY_DEFINE_NAME', 'THE_VALUE');.

Then in your templates you can show the value like this: echo MY_DEFINE_NAME;

Or set the value to a variable: $var = MY_DEFINE_NAME;.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744702269a4588842.html

相关推荐

  • How to create custom variables in the wp-config

    I would like to add some custom config variables in the wp-config.php file (not in the functions.php). Then, I need to a

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信