Whenever you do get_posts or WP_Query or anything like that, it’s important to remember that the code is actually getting all of the Posts at once, and loading them from the database into memory. If you run out of memory, then your process will simply die with an error. Attempting to get very large numbers of posts at once will cause this quite often.
Turn on PHP’s display_errors. You’ll likely see an out of memory error.
Next, bump up the PHP memory_limit setting to 128M or 256M and see if you now have enough memory to do it.
Alternately, rewrite your get_posts to use pagination. Get them 100 at a time or something along those lines. Then you’re not trying to pull 1000s of posts into memory all at once.
Related Posts:
- Cron task firing but function not working
- How to test wp_cron?
- How do I get posts by multiple post ID’s?
- Running WP Cron on multisite the right way
- WP Cron Doesn’t Execute When Time Elapses
- What does setup_postdata ($post ) do?
- Query for custom post type? [closed]
- setup_postdata() does not seem to be working?
- Regenerate Slugs From Title of Posts
- get_posts – get all posts by author id
- Why get_posts are only showing five posts (retrieved by assigning a category to them?
- Exclude Current Post from Recent Posts Loop
- WordPress get_posts by category
- Do WordPress cron jobs slow down page loading?
- get_post random and order by not working
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- WordPress cron isn’t scheduled on amazon web services
- Running WordPress on the Command Line – Turn off Delayed Output?
- Schedule WordPress Auto-Updates to only run during business hours
- Alternative to get_posts() due to multithreading cache crash
- How is WP Cron Locking implemented?
- How to get current post ID in quick edit callback
- get_posts with meta_compare=’LIKE’ not working
- Better handling of WP-CRON server load abuse
- When does next Cron Job run (time from now)?
- Get frequency of scheduled event
- How to restore deleted pages/posts?
- Sort “get_pages” by menu order not ordering
- get posts based on meta value of the author
- date_query not returning some posts in date range
- Get the exact SQL query that get_posts() generated
- Need to execute a cron job
- How do you get posts by meta_query using the JSON API plugin?
- run a cron task without obstructing page load?
- crontab wp-cron.php on multisite path-based network: one for each path? Or just one for the root?
- Recurring scheduled task help
- Why favour the standard WP loop over iterating over (new WP_Query())->get_posts()?
- Query posts ordering by title, but ignore ” and special characters
- What happens when wp_cron is deactivated in WordPress?
- Running wp-cron from CLI
- How to make wp cron job not fire immediately?
- How Do I Make WordPress Run an Event Every Day?
- get_posts / WP_Query Memory size of 134217728 bytes exhausted
- Hourly WP schedule, do I need at least 1 visitor hourly?
- Initialize WordPress environment to use in a real cron script
- Why?: hundreds of empty files named wp-cron.php?doing_wp_cron.
- Can’t access wp_filesystem in cron function
- WP CRON runs only the first time
- Multiple wp_schedule_event cron jobs in plugin cause multi-execution
- get_posts not honoring post_status
- WP Cron emails not working
- Trigger a cron every 24h GMT -8
- get_posts returning empty array
- WordPress Cron Schedule the if and else statement
- Schedule event every second thursday of the month
- get_posts only children from certain parents
- Problem with get_posts, tax_query and counting the number of posts
- Automated mark posts as featured every day
- Auto Delete Users (auto_delete_users)
- get_posts cannot grab from specific category
- Filtering custom post type query
- Is there any background process that I can run from plugin without depending on page hits on a website without affecting page-load speed?
- WordPress cron running twice
- Scheduled Posts and wp-cron – Why don’t scheduled posts publish if too old?
- wp_schedule_single_event function not working
- How ( and mostly at what time ) can i prevent the alternate cron from running?
- How do i schedule cron in wordpress for each second?
- Check If posts exist in custom post type category, outside of loop
- Check if event was scheduled – schedule event only once
- data returned from get_post($postId) have different keys than wp-json/wp/v2/posts/{postId}
- How to limit get_posts()?
- meta_query date and time comparisons
- get_posts from post x(offset=>x) to end
- With get_posts(), how can I put a category as a variable
- What’s the difference between “get_posts” and “wp_get_recent_posts” when used with “setup_postdata”?
- Serialized array, grab specific posts with meta_key/meta_value[0]->is_featured
- How do I combine these 2 queries
- get_posts gives different result than wpdb->get_results
- Increase the page size of the WordPress REST API
- How to notify the admin about something that happened during a cron job
- Create function in functions.php with hook name to execute URL
- How to remove unused avatar uploads in buddypress [closed]
- How to generate a list of posts published on current day?
- cron.php being constantly deleted [closed]
- Scheduling posts on wordpress adds wrong seconds as post_date
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- Trouble using get_post
- Cache Get_posts
- WP Cron job every 1st and 15th of the month
- Get latest posts from multiple categories
- get_posts() returns all posts rather than the ones specified with ‘post_author’ =>
- Query random post from different categories
- Template Tag not available in real Cron Jobs
- Get_Posts, only if in both categories
- WordPress Caching – Transients API or “update_user_meta ” Cronjob?
- Why is wp-cron only executing on page visit?
- Will cron job run if page loaded is being served from cache?
- Posts not showing in correct Alphabetical or ID order when using get_posts / orderby but only on production server
- get_posts() excluding all children of a specific post/page
- wp_schedule_event run in background or not?