Changeset 13944 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/inc/query.php
- Timestamp:
- 08/02/2024 12:26:40 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/inc/query.php
r13943 r13944 8 8 add_action( 'pre_get_posts', __NAMESPACE__ . '\add_language_to_archive_queries' ); 9 9 add_action( 'pre_get_posts', __NAMESPACE__ . '\add_excluded_to_lesson_archive_query' ); 10 add_action( 'pre_get_posts', __NAMESPACE__ . '\filter_search_queries_by_post_type' ); 10 11 add_filter( 'request', __NAMESPACE__ . '\handle_all_level_query' ); 11 12 … … 82 83 83 84 /** 85 * Filter search queries by post type. 86 * Only include courses and lessons in search results unless post_type is set, eg. for an archive search. 87 * 88 * @param WP_Query $query The query object. 89 * @return WP_Query The modified query object. 90 */ 91 function filter_search_queries_by_post_type( $query ) { 92 if ( ! is_admin() && $query->is_search() && $query->is_main_query() ) { 93 if ( ! $query->get( 'post_type' ) ) { 94 $query->set( 'post_type', array( 'course', 'lesson' ) ); 95 } 96 } 97 98 return $query; 99 } 100 101 /** 84 102 * Modify the request. 85 103 *
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)