PHP help get_template_directory + PHP include

Sorry my PHP skills are lacking.

I want to use a php include in WP but I’d like to get the file path with <?php get_template_directory(); ?>

Read More

I can’t figure out how that would look.

My non WP file looks like this:

<?php include 'inc/social.php'; ?>

Basically I don’t know how to string two PHP commands together get_template_directory + include.

Related posts

1 comment

  1. get_template_directory() and get_stylesheet_directory() both pull form the wp-content/themes directory. The difference being that the former always pulls from the parent theme directory.

    Neither take parameters, so you just concatenate the rest of the path to the string returned from the appropriate function. That is:

    include get_template_directory().'/inc/social.php';
    

    If your file is not in your theme directory, you cannot use those functions. They are very specifically theme functions.

Comments are closed.