1. Home
  2. Docs
  3. Function Reference
  4. Functions
  5. include()

include()

Loads additional files. JavaScript and CSS files are enqueued, PHP files are included.

Copy to Clipboard

Parameters

$files

Associative array of files: handle => filepath Files are searched for from the active theme directory.

$is_child_first

If files can be used from the child theme (default true)

$depths

Arrays of CSS, JS & PHP dependency handles (default empty)

$can_show_error

If an error should be shown for non-existent files (default false)

$attrs

Array of attributes, see online documentation (default empty)

Return

$depths

Arrays of CSS, JS & PHP dependency handles

Example

Simple enqeuing of JavaScript files in a front controller.

Copy to Clipboard

In the admin area, presuming that you are working on a post, and you’ve created a post.js in /mvc/admin/js/, then in your controller: ctrl_mvc_admin_post.class.php

Copy to Clipboard

At the frontend

Copy to Clipboard
Tags