-
-
Save kevinwhoffman/7ae4f4541f62562e485ba4d05e8dd3b3 to your computer and use it in GitHub Desktop.
Filter WordPress category archive to display Learndash Lessons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function filter_category_archive_to_display_lessons( $query ) { | |
if ( ! is_admin() && $query->is_main_query() ) { | |
// Not a query for an admin page. | |
// It's the main query for a front end page of your site. | |
if ( is_category() ) { | |
// It's the main query for a category archive. | |
// Let's change the query for category archives to only display lessons. | |
$query->set( 'post_type', 'sfwd-lessons' ); | |
} | |
} | |
} | |
add_action( 'pre_get_posts', 'filter_category_archive_to_display_lessons' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment