Created
May 22, 2026 08:17
-
-
Save propertyhive/ef68131ec9587e440bb01ceb10384e44 to your computer and use it in GitHub Desktop.
Put offices in a specific order
This file contains hidden or 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
| add_action( 'pre_get_posts', function( $query ) { | |
| if ( is_admin() || ! $query->is_main_query() ) { | |
| return; | |
| } | |
| // Adjust this condition if the plugin uses a shortcode/custom query. | |
| if ( $query->get( 'post_type' ) !== 'office' && ! is_post_type_archive( 'office' ) ) { | |
| return; | |
| } | |
| // LIST YOUR OFFICE IDS HERE IN THE ORDER YOU WANT | |
| $office_order = array( | |
| 123, | |
| 456, | |
| 789, | |
| 321, | |
| ); | |
| $query->set( 'post_type', 'office' ); | |
| $query->set( 'post__in', $office_order ); | |
| $query->set( 'orderby', 'post__in' ); | |
| $query->set( 'posts_per_page', -1 ); | |
| }, 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment