最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - Max Posts and Memory Limit

programmeradmin1浏览0评论

So I have a custom post type which uses ACF Metaboxes that contains over 750 posts and grwoing. I got the infamous white screen of death because it seems like PHP has exhaused it's memory limit querying all these posts and data. I set my PHP.INI file's max execution time and memory limit to -1 and increased my WP's memory limit in config to define('WP_MEMORY_LIMIT', '4096M');

yet I'm still receiving a white screen of death in the admin when trying to view the custom post type. Any ideas on how to fix/increase memory?

Thanks

So I have a custom post type which uses ACF Metaboxes that contains over 750 posts and grwoing. I got the infamous white screen of death because it seems like PHP has exhaused it's memory limit querying all these posts and data. I set my PHP.INI file's max execution time and memory limit to -1 and increased my WP's memory limit in config to define('WP_MEMORY_LIMIT', '4096M');

yet I'm still receiving a white screen of death in the admin when trying to view the custom post type. Any ideas on how to fix/increase memory?

Thanks

Share Improve this question asked May 30, 2014 at 19:53 RizzoRizzo 2696 silver badges20 bronze badges 6
  • Are you fetching 750 posts at once. Is that really necessary? Profile your page. I wonder how many db queries you got on each page load. – birgire Commented May 30, 2014 at 20:16
  • I should clarify, you're right. When I query lest posts on the front end, it's all good. It's the admin post type view where I'm having the problem, fore example: wp-admin/edit.php?post_type=books – Rizzo Commented May 30, 2014 at 20:38
  • Do you have WP_DEBUG enabled in wp-config.php? What makes you think that PHP is exhausting it's memory limit; do you know this for sure or are you guessing? – bosco Commented May 30, 2014 at 20:44
  • 1 Alright, that's a good start - it appears to be crapping out in the $wpdb->get_results() method, which could well indicate that some query is returning an obscure amount of data. Do you have WP_DEBUG enabled in wp-config.php? I would also enable WP_DEBUG_LOG so any errors get logged into the wp-content directory. Any WordPress-generated errors or warnings show up? I feel like this may have something to do with the internals of ACF Metaboxes which I'm entirely unfamiliar with, so I'm not sure how much more help I will be... – bosco Commented May 30, 2014 at 21:36
  • 1 As @birgie suggested, profiling the page load would prove to be a large step in troubleshooting this issue. – bosco Commented May 30, 2014 at 21:37
 |  Show 1 more comment

1 Answer 1

Reset to default 1

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' );
}
发布评论

评论列表(0)

  1. 暂无评论