A way to organize theme files and include them on right actions
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
includes
widgets/demo-test
README.md
helpers.php
hooks.php
init.php
menus.php
static.php

README.md

Theme Includes

A way to organize theme files.

Directory Structure

theme/
└─inc/
  ├─static.php     # wp_enqueue_style() and wp_enqueue_script()
  ├─menus.php      # register_nav_menus()
  ├─hooks.php      # add_filter() and add_action()
  ├─helpers.php    # Helper functions and classes
  ├─widgets/       # Theme widgets
  │ ├─{widget-name}/
  │ │ ├─class-widget-{widget-name}.php # class Widget_{Widget_Name} extends WP_Widget { ... }
  │ │ ├─some-file.php
  │ │ └─some-dir/
  │ │   └─...
  │ └─...
  └─includes/      # All .php files are auto included (no need to require_once)
    ├─some-file.php
    └─...

File Descriptions

  • helpers.php, hooks.php, includes/*.php are included right away
  • static.php is included on wp_enqueue_scripts action
  • widgets/{hello-world}/class-widget-{Hello_World}.php are included on widgets_init action

Install

  1. Download the archive
  • Extract it to your theme root directory

  • Include the init.php file from your theme functions.php

     include_once get_template_directory() .'/inc/init.php';