Support » Plugin: Custom Post Type UI » Custom Post Type ASC Order WP-Admin

  • Resolved Columbus

    (@christof15)


    // CUSTOM POST TYPE ORDER ABC
    function pluginize_order_cpt_by_title( $query ) {
    	if ( ! is_admin() ) {
    		return;
    	}
    	if ( ! $query->is_main_query() ) {
    		return;
    	}
    	$screen = get_current_screen();
    	if ( ! is_object( $screen ) ) {
    		return;
    	}
    	if ( 'YOUR-CUSTOM-POST-TYPE' === $screen->post_type ) {
    		$query->set( 'orderby', 'title' );
    		$query->set( 'order', 'ASC' );
    	}
    }
    add_action( 'pre_get_posts', 'pluginize_order_cpt_by_title' );
    //
    • This topic was modified 1 year, 4 months ago by Columbus.
    • This topic was modified 1 year, 4 months ago by Columbus.
    • This topic was modified 1 year, 4 months ago by Columbus.
    • This topic was modified 1 year, 4 months ago by Columbus.
    • This topic was modified 1 year, 4 months ago by Columbus. Reason: Found solution for ASC order
  • The topic ‘Custom Post Type ASC Order WP-Admin’ is closed to new replies.