Skip to content

Instantly share code, notes, and snippets.

@kimcoleman
Created November 25, 2024 19:35
Show Gist options
  • Save kimcoleman/c8701f4d791beb1d93300bf3076b8cbc to your computer and use it in GitHub Desktop.
Save kimcoleman/c8701f4d791beb1d93300bf3076b8cbc to your computer and use it in GitHub Desktop.
Modify the pmpro_lesson post type args to allow comments.
<?php
function modify_pmpro_lesson_post_type_args($args, $post_type) {
// Target only the 'pmpro_lesson' post type
if ($post_type === 'pmpro_lesson') {
// Merge 'comments' (discussion) support into the 'supports' array
if (isset($args['supports']) && is_array($args['supports'])) {
$args['supports'][] = 'comments'; // Add 'comments' support
} else {
$args['supports'] = array('comments'); // Create the supports array if it doesn't exist
}
}
return $args;
}
add_filter('register_post_type_args', 'modify_pmpro_lesson_post_type_args', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment