Filter
uncanny-automator
automator_recipe_post_types
Filters the list of post types that can be used to create automator recipes.
add_filter( 'automator_recipe_post_types', $callback, 10, 1 );
Description
Fires when retrieving the post types used for recipes. Developers can filter this array to include or exclude specific post types from being recognized as recipe components, offering granular control over recipe builder functionality.
Usage
add_filter( 'automator_recipe_post_types', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to filter the automator_recipe_post_types hook.
* This example demonstrates removing the AUTOMATOR_POST_TYPE_LOOP from the list
* of post types considered as recipes.
*/
add_filter( 'automator_recipe_post_types', 'my_custom_automator_recipe_post_types', 10, 1 );
function my_custom_automator_recipe_post_types( $post_types ) {
// Check if AUTOMATOR_POST_TYPE_LOOP exists in the array and remove it.
if ( ( $key = array_search( AUTOMATOR_POST_TYPE_LOOP, $post_types, true ) ) !== false ) {
unset( $post_types[ $key ] );
}
// You could also add new post types if needed, but ensure they are registered correctly.
// Example: $post_types[] = 'my_custom_automator_post_type';
return $post_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:58
function automator_get_recipe_post_types() {
return apply_filters(
'automator_recipe_post_types',
array(
AUTOMATOR_POST_TYPE_RECIPE,
AUTOMATOR_POST_TYPE_TRIGGER,
AUTOMATOR_POST_TYPE_ACTION,
AUTOMATOR_POST_TYPE_CLOSURE,
AUTOMATOR_POST_TYPE_LOOP,
AUTOMATOR_POST_TYPE_LOOP_FILTER,
// AUTOMATOR_POST_TYPE_BLOCK,
// AUTOMATOR_POST_TYPE_FILTER_CONDITION,
)
);
}