You’re on the right path with your add_filter
, but this is the right way to implement filters.
add_filter( 'gigpress_related_post_types', 'my_related_post_types' );
function my_related_post_types( $post_types ) {
return array( 'productions' );
}
The hook add_filter
must call a function that returns something to pass to the apply_filters
in the code you referenced.
You should add in whatever logic you need to return the correct post types and handle the default as well. For example:
add_filter( 'gigpress_related_post_types', 'my_related_post_types' );
function my_related_post_types( $post_types ) {
// Assuming you set an option to control which post types should be used.
$custom_gig_post_types = get_option( 'gig_post_types', false );
if ( $custom_gig_post_types ) {
return $custom_gig_post_types;
}
return $post_types;
}