Filter uncanny-automator

automator_loop_child_types

Filters the available post types that can be used as loop child types within the plugin.

add_filter( 'automator_loop_child_types', $callback, 10, 1 );

Description

Filters the array of available post types that can be used as children within loops. Developers can use this to add or remove custom post types that function as loop children, allowing for greater flexibility in workflow automation. The hook fires during the retrieval of loop child types.


Usage

add_filter( 'automator_loop_child_types', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

/**
 * Example of how to filter the automator_loop_child_types hook.
 *
 * This example will remove the 'automator_post_type_closure' from the
 * list of allowed child types for loops.
 */
add_filter( 'automator_loop_child_types', 'my_custom_automator_loop_child_types', 10, 1 );

function my_custom_automator_loop_child_types( $child_types ) {
    // Check if 'automator_post_type_closure' exists in the array.
    if ( ( $key = array_search( AUTOMATOR_POST_TYPE_CLOSURE, $child_types ) ) !== false ) {
        // Unset it if found.
        unset( $child_types[ $key ] );
    }

    // Return the modified array of child types.
    return $child_types;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/global-functions.php:102

function automator_get_loop_child_types() {

	return apply_filters(
		'automator_loop_child_types',
		array(
			AUTOMATOR_POST_TYPE_ACTION,
			AUTOMATOR_POST_TYPE_CLOSURE,
			AUTOMATOR_POST_TYPE_LOOP_FILTER,
			// AUTOMATOR_POST_TYPE_BLOCK,
			// AUTOMATOR_POST_TYPE_FILTER_CONDITION,
		)
	);
}


Scroll to Top