Including multiple files

There are different ways to include multiple files.

The functions file can fairly fast become very long with a lot of code. One can then split off the code into logical files and then add the file to the functions file.

require_once( get_stylesheet_directory() . '/inc/widgets.php' );

get_stylesheet_directory = To get the absolute path to the child theme directory.
get_stylesheet_uri = looking through the child theme directory (is short for get_stylesheet_directory_uri()). Is used to retrieve the style.css file.

get_template_directory = looks to the parent theme.
get_template_directory_uri = looks to parent directory to retrieve the style.css file.

Examples of enqueuing js and css files

// Example from:
wp_enqueue_script( 'script', get_template_directory_uri() . 
'/js/script.js', array ( 'jquery' ), 1.1, true);
//* Enqueue Google fonts -
add_action( 'wp_enqueue_scripts', 'load_google_fonts' );
function load_google_fonts() {
 wp_enqueue_style( 'google-font-oswald', '//', array(), 1.0 );

//* Enqueue sticky menu script
add_action( 'wp_enqueue_scripts', 'custom_enqueue_script' );
function custom_enqueue_script() {
 wp_enqueue_script( 'sticky-menu', get_stylesheet_directory_uri() . 'assets/js/sticky-menu.js', array( 'jquery' ), '', true );

//* Loading Font Awesome -
add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
function enqueue_font_awesome() {
 wp_enqueue_style( 'font-awesome', '//' );



No comment yet, add your voice below!

Add a Comment

Your email address will not be published. Required fields are marked *

Comment *
Name *
Email *