0

I made a config.php file where I store some arrays for configuration like LDAP and other things. I need to call it on different templates but I also need to require it into function.php.

When I do this this, I have warning and all my tables become Undefined.

EDIT

I found this solution : call my config.php into functions.php with : require ( get_template_directory() . '/config.php' );

Replaced this require from all my tempate/views by global $ARRAY_NAME;

1
  • Show some code?
    – vancoder
    Sep 22, 2021 at 17:15

2 Answers 2

0

It is depends on where your config.php file is located. Write code in active theme's functions.php

  1. If file is on root of WordPress installtion: require_once(ABSPATH .'config.php');

  2. If it is on active Theme's root directory: require_once('config.php');

0

@Baikare Sandeep : Hi, it is not a path problem. my config.php is at the theme's root. I can access it in my templates and functions.php with require ( get_template_directory() . '/config.php' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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