Changeset 12268 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/functions.php
- Timestamp:
- 11/23/2022 02:00:20 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/functions.php
r12067 r12268 341 341 // Some lesson plans were created at exactly the same second, so we're adding the ID to the implicit sort order to avoid randomization. 342 342 if ( 343 ( $query->is_post_type_archive( 'lesson-plan' ) || $query->is_tax( ' wporg_lesson_category' ) ) &&343 ( $query->is_post_type_archive( 'lesson-plan' ) || $query->is_tax( 'topic' ) ) && 344 344 empty( $query->get( 'orderby' ) ) 345 345 ) { … … 1202 1202 } 1203 1203 add_filter( 'mime_types', 'wporg_learn_mime_types' ); 1204 1205 /** 1206 * Get the sticky Topic terms, with the selected topic first 1207 * 1208 * @param string $first The slug of the topic to return first. 1209 * @return array 1210 */ 1211 function wporg_learn_get_sticky_topics_with_selected_first( $first = 'general' ) { 1212 $first_topic; 1213 $topics = array(); 1214 $all_topics = get_terms( array( 1215 'taxonomy' => 'topic', 1216 'hide_empty' => false, 1217 ) ); 1218 1219 foreach ( $all_topics as $topic ) { 1220 $is_sticky = get_term_meta( $topic->term_id, 'sticky', true ); 1221 1222 if ( $is_sticky ) { 1223 if ( $topic->slug === $first ) { 1224 $first_topic = $topic; 1225 } else { 1226 array_push( $topics, $topic ); 1227 } 1228 } 1229 } 1230 1231 if ( isset( $first_topic ) ) { 1232 array_unshift( $topics, $first_topic ); 1233 } 1234 1235 return $topics; 1236 }
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)