Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
Hi can you get answer of this question. please i need this functionality. thank you –  renishkhunt Apr 21 at 6:53
    
I accepted the following answer, just add your custom variable with a define –  aguidis 2 days ago
add comment

1 Answer

up vote 1 down vote accepted

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;.

share|improve this answer
    
Thank you for your quick answer. I need to store some page IDs. The page IDs depend of environments (dev, production etc...). Moreover the functions.php is subversionned contrary to the wp-config.php. This is why I need to store some datas in this file. –  aguidis Aug 13 '13 at 13:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.