Skip to content

Conditions

Renato Alves edited this page Aug 10, 2026 · 1 revision

Conditions

The condition parameter determines under which condition(s) the asset should load.

include

string|array

Requires that all conditions be truthy in order for the asset to load.

The include property is implied if the condition parameter is a string or array of strings; otherwise the condition parameter must contain the include property.

include_any

string|array

Allows for any condition to be truthy, instead of requiring that all conditions be.

exclude

string|array

Requires that all conditions be falsey in order for the asset to load. This is skipped if neither include nor include_any are truthy.

Custom Conditions

There are a few default conditions included out-of-the-box:

Name Condition
'global' true
'single' is_single()
'search' is_search()

Use the am_asset_conditions filter to add or replace conditions.

function asset_conditions( $conditions ) {
  return array_merge(
    $conditions,
    [
      'home'    => ( is_home() || is_front_page() ),
      'archive' => is_archive(),
      'page'    => is_page(),
    ]
  );
}

add_filter( 'am_asset_conditions', 'asset_conditions', 10 );

Clone this wiki locally