Satch3000
Satch3000

Reputation: 49384

PHP Include with a twist

I have an include

include ('myfile.php');

Now, I am using wordpress and to get the template path I use:

<?php echo get_template_directory_uri(); ?>

My question is:

How can I use both together?

Like:

<?php

include('<?php echo get_template_directory_uri(); ?>/myfile.php');

?>

Thanks

Upvotes: 1

Views: 1634

Answers (2)

Zoda
Zoda

Reputation: 21

You can use the result of the function in the include, but not by echo:ing it. Just use it directly.

<?php
include(get_template_directory_uri() . '/myfile.php');

Upvotes: 2

Brad
Brad

Reputation: 163272

include(get_template_directory_uri() . "/myfile.php");

The include() function just takes a string parameter. Nothing special about it.

Upvotes: 6

Related Questions