apply_filters( 'learndash-cpt-options', array $cpt_args, string $post_type )
Filters the custom post type arguments.
Description #
Parameters #
- $cpt_args
-
(array) Custom post type arguments.
- $post_type
-
(string) Post type.
Source #
Examples #
Note: Extended code example below not guaranteed, you may need to consult with a developer
<?php
/**
* Example usage for learndash-cpt-options filter.
*/
add_filter(
'learndash-cpt-options',
function( $post_args = array(), $post_type_slug = '' ) {
if ( 'sfwd-assignment' === $post_type_slug ) {
if ( ( isset( $post_args['supports'] ) ) && ( ! empty( $post_args['supports'] ) ) && ( is_array( $post_args['supports'] ) ) ) {
// Simple method to compare the 'supports' array and return all but the 'comments' element.
$post_args['supports'] = array_diff( $post_args['supports'], array( 'comments' ) );
}
}
// always return the $post_args array
return $post_args;
},
10,
2
);