PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 5, 2022

[FIXED] Include external files in functions.php WordPress

 February 05, 2022     php, wordpress     No comments   

Issue

In my WordPress I have a functions.php file containing 1500 lines of code.

Most of this code comes from a program I wrote that connects to an API and sends data from WordPress to it. I am not a WordPress developer, so I do not know if this is possible. Can you make a different file to keep functions.php clean and then include the external file inside the functions.php?


Solution

You can include external files in functions.php by using either

require_once();

or else you can use

include_once();

The difference between these two is that in the event that the file is not found require will give out a fatal error and then stop executing the rest of the file where as include will only issue a warning but will continue the execution of the file.



Answered By - Vihanga Bandara
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing