Max Posts and Memory Limit

For me, this was happening b/c of post meta cache issues. This article suggested code which solved my issue – and apparently many other’s as well.

https://junaid.dev/wordpress-admin-fix-fatal-error-allowed-memory-size-error/?unapproved=369&moderation-hash=bd9064ea40d413150d8a42599c13f4f5#comment-369

Here is the code he provides:

function jb_pre_get_posts( WP_Query $wp_query ) {
    if ( in_array( $wp_query->get( 'post_type' ), array( 'my_post_type_1', 'my_post_type_2' ) ) ) {
        $wp_query->set( 'update_post_meta_cache', false );
    }
}

// Only do this for admin.
if ( is_admin() ) {
    add_action( 'pre_get_posts', 'jb_pre_get_posts' );
}