Skip to content

Instantly share code, notes, and snippets.

@ideadude
Created October 8, 2021 13:41
Show Gist options
  • Save ideadude/961042ea2bc1685d44ffdbef0de724f3 to your computer and use it in GitHub Desktop.
Save ideadude/961042ea2bc1685d44ffdbef0de724f3 to your computer and use it in GitHub Desktop.
Update the PMPro Courses Lessons CPT to have a frontend archive page.
<?php
/**
* Update the PMPro Courses Lessons CPT to have a frontend archive page.
* Add this code into a custom plugin or Code Snippet.
* After adding this code, visit Settings -> Permalinks and save to
* 'flush the rewrite rules'.
* Then visit /lessons/ on your site.
* You can style this archive by adding a file named archive-pmpro_lesson.php
* to your child theme or theme.
*/
function my_pmpro_lessons_has_archive( $args, $post_type ){
if ( $post_type == 'pmpro_lesson' ){
$args['has_archive'] = 'lessons';
}
return $args;
}
add_filter( 'register_post_type_args', 'my_pmpro_lessons_has_archive', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment