eventsmanager

Sort WP-Admin Events

May 29th, 2025
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. <?php
  2.  
  3. function set_default_sort_for_custom_post_type( $query ) {
  4. if ( is_admin() && $query->is_main_query() ) {
  5. // Specify the custom post type you want to target
  6. if ( 'event' === $query->get( 'post_type' ) ) {
  7. // Set the default order and orderby parameters
  8. $query->set( 'orderby', 'event_id' );
  9. $query->set( 'order', 'DESC' );
  10. }
  11. }
  12. }
  13. add_action( 'pre_get_posts', 'set_default_sort_for_custom_post_type' );
Advertisement
Add Comment
Please, Sign In to add comment