Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails

I am running the latest WordPress version (4.6) on a LAMP server (shared hosting) with PHP version 5.6.12. I am trying to programmatically add 10 images, uploaded with ftp to the wp-uploads directory, to the media library using the three WordPress functions wp_insert_attachment, wp_generate_attachment_metadata and wp_update_attachment_metadata. My problem: Sometimes, my PHP script works (all 10 … Read more

What is a “cache-friendly” code?

What is the difference between “cache unfriendly code” and the “cache friendly” code? How can I make sure I write cache-efficient code? 9 s 9 Preliminaries On modern computers, only the lowest level memory structures (the registers) can move data around in single clock cycles. However, registers are very expensive and most computer cores have … Read more

What’s the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

What’s the difference beetween define( ‘WP_MEMORY_LIMIT’, ’96M’ ); and define( ‘WP_MAX_MEMORY_LIMIT’, ‘256M’ ); In my host I have this define( ‘WP_MEMORY_LIMIT’, ‘786M’ ); define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ ); is this correct, should the WP_MAX_MEMORY_LIMIT be higher ? 2 s 2 WordPress tells us: the WP_MEMORY_LIMIT option allows you to specify the maximum amount of memory that … Read more

WP_Query leaking absurd amounts of memory

Every time I call WP_Query() in the function below, WordPress leaks 8 megs of memory. And since I call this function a lot, things get hairy pretty quickly… 🙁 I’ve tried unsetting the resulting $queryObject as well as periodically calling wp_cache_flush(), but neither seems to have any effect. Any thoughts? function get_post_ids_in_taxonomies($taxonomies, &$terms=array()) { $post_ids … Read more