Moderator
t-p
(@t-p)
If understand you, have you tried creating /mu-plugins/ directory and placing this echo-values.php inside it?
Looks like this: /wp-content/plugins/mu-plugins/echo-values.php
http://codex.wordpress.org/Must_Use_Plugins
Thread Starter
WPOso
(@wordpress-oso)
Actually, this turned into two problems, one of which I just solved. As you suggested, I created a new folder – mu-plugins – put my file inside it, and it does autoload.
However, I still need to know how to write includes.
The file inside my mu-plugins folder is fine for creating echo values, but if I want to actually display something at the beginning of an article or at the bottom of the page, then I need to be able to insert an include in the proper location.
Also, I’m eventually going to put some database-driven reference tables on some of my pages, so I’ll have to include separate files that feature queries and a lot of styling, etc.
Anyway, what’s the proper way to write an include?
Moderator
t-p
(@t-p)
I don’t follow what you are trying to do. Perhaps someone else can chime in.
There are plugins to include fies with a short code. and plugins to execute php in a post. and if your brave custom fields.
Thread Starter
WPOso
(@wordpress-oso)
I found a couple custom fields plugins. Can you list any plugins that help you include PHP files? Thanks.
You have so many choices; you could:
1) create a simple shortcode that inserts php. That code could go into functions.php or in a plugin. See https://codex.wordpress.org/Shortcode_API. Gives you want the flexibility to put the code anywhere you like within post content.
Or 2) put that code into one of your theme’s files. If you’re not using a child theme, please do so! Then that code could go within one or more of the template file in the child theme. Not as flexible as using a shortcode, but still a viable option.
Or 3) put that code into a widget. Which makes sense if you’ll mainly want to place it within widgetised areas. http://www.wpbeginner.com/wp-tutorials/how-to-create-a-custom-wordpress-widget/
Or 4) use a plugin such as https://wordpress.org/plugins/insert-php/ to insert PHP into any post.
Thread Starter
WPOso
(@wordpress-oso)
Thanks, I’ll check those out.