1

I am trying to include a template file into a loop i made in a shortcode, in a plugin. Everything shows up fine when the template is actually pasted into the loop, but to make things neat I want to separate it into it's own file.

I created a file called hi.php and it's located in a plugin subfolder called parts.

Here is the code I place in the loop, but it is not loading the template:

include plugins_url( '/parts/hi.php', __FILE__ );

2

I do it like this:

// Inclusion of additional php files
define( 'MYPLUG_DIR', plugin_dir_path( __FILE__ ) );

require_once( MYPLUG_DIR . 'hi.php' );

It lets you use that more easily if you have to include several files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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