Timeline for How To Add Code To WP Without Plugin or Functions
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 26, 2017 at 2:58 | comment | added | Crazycoolcam | You're welcome. Glad to help! | |
Sep 25, 2017 at 22:58 | vote | accept | CodeMilitant | ||
Sep 25, 2017 at 22:56 | comment | added | CodeMilitant |
include( WP_CONTENT_DIR . '/custom-shortcodes.php' ); This allows for the functionality of a plugin, and nothing shows up in the WordPress Admin. While I didn't test it, you should be able to symlink to the file and put it above wp-content . I accepted your answer because it pointed me in the right direction. Thank you.
|
|
Sep 25, 2017 at 22:47 | comment | added | CodeMilitant |
I did figure this out, and it solves my problem. I added a reference in my functions.php file to the file I want WP to run. Like this:
|
|
Aug 19, 2017 at 22:29 | comment | added | Crazycoolcam | I think one catch is that if your code needs to reference any actions/hooks in WP or interface with the DB, wp-config is too early. I don't think the action/filter hooks are set up and the connection to the DB happens right after wp-config is loaded (since it has your DB info in it). I know what you are asking is possible (the DesktopServer software does this and adds plugins without my knowledge of where the code is for these plugins), but I don't know how it does it. | |
Aug 19, 2017 at 12:56 | comment | added | CodeMilitant |
I like your idea about using the require line in the wp-config file, and I've been experimenting with it. Unfortunately, I've had no luck. I don't have a PHP program to debug issues, but I like your idea the best. I thought I could do like I have with my wp-content/uploads folder. I symlinked this folder to a dedicated drive. I thought I could just reference the file, and then it would work. However, a plugin must be activated, and this is failing. Ideally I don't want WordPress to see my custom code as a plugin, but at the moment, I can't get it to parse my files. Any ideas?
|
|
Aug 17, 2017 at 21:06 | history | answered | Crazycoolcam | CC BY-SA 3.0 |