Development

The Loop

Action Hooks

Enqueue Files

// wp-content/themes/{my_theme}/functions.php

function add_theme_scripts() {
    wp_enqueue_style('slider', get_template_directory_uri() . '/css/slider.css', array(), '1.1', 'all');
    wp_enqueue_script('script', get_template_directory_uri() . '/js/script.js', array('jquery'), 1.1, true);
}
add_action('wp_enqueue_scripts', 'add_theme_scripts');

Enqueue CSS Files

wp_enqueue_style($handle, $src, $deps, $ver, $media);

Parameter Required Description
handle Yes The name of the stylesheet. Should be unique.
src Yes The URL for the file.
deps No Refers to whether or not this stylesheet is dependent on another stylesheet. If this param is set, this stylesheet will not be loaded unless its dependent stylesheet is loaded first.
ver No An arbitrary version number.
media No Specify which type of media to load this stylesheet in, such as ‘all’, ‘screen’, ‘print’ or ‘handheld.’

Enqueue JS Files

wp_enqueue_script($handle, $src, $deps, $ver, $in_footer);

Parameter Required Description
handle Yes The name of the script. Should be unique.
src Yes Full URL of the script, or path of the script relative to the WordPress root directory.
deps No An array of registered script handles this script depends on.
ver No String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.
in_footer No Whether to enqueue the script before instead of in the . Default ‘false’.

Prevent WP Auto Updates

# Disable all automatic WP updates.
define('AUTOMATIC_UPDATER_DISABLED', true);

# Disable automatic WordPress plugin updates:
add_filter( 'auto_update_plugin', '__return_false' );

# Disable automatic WordPress theme updates:
add_filter( 'auto_update_theme', '__return_false' );

add_filter( 'automatic_updater_disabled', '__return_true' );
add_filter( 'auto_update_plugin', '__return_false' );
add_filter( 'auto_update_theme', '__return_false' );
add_filter( 'auto_update_translation', '__return_false' );

AJAX

Debugging

Debug Mode

  • WordPress debugging mode displays PHP notices during development.
  • It is strongly recommended that plugin and theme developers use WP_DEBUG in their development environments.
  • Debugging in WordPress (codex.wordpress.org)
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);