How can I add programmatically custom taxonomy terms to a custom type post when saving posts?

So, to answer my own question: I haven’t found any solution inside wp_insert_post_data. I suspect that the problem is connected to the fact that when wp_insert_post_data is executed the post in question is not yet in the database. And albeit I didn’t manage to find it in taxonomy.php, it is logical to assume that the … Read more

Modify featured image path to Amazon S3

You can hook into the output and modify the URL there. add_filter( ‘post_thumbnail_html’, ‘my_post_image_html’, 10, 5 ); function my_post_image_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) { $upload_dir = wp_upload_dir(); $base_url = $upload_dir[‘baseurl’]; // Change the default upload directory to AWS Bucket link $AWSBucket=”http://s3.amazonaws.com/bucket”; $html = str_replace($base_url, $AWSBucket, $html); return $html; } Output the image echo … Read more

How does W3 Total Cache CDN URL rewrites work? [closed]

The W3 Total Cache plugin changes the URL of various files in /w3-total-cache/lib/W3/Plugin/Cdn.php in the function *ob_callback*. It uses a series of callbacks to modify an output buffer. The code runs like this: w3_total_cache.php calls $root->run(); W3_Root::run calls $plugin->run() for each plugin in $this->_loaded_plugins W3_Plugin_TotalCache::run starts an output buffer which calls W3_Plugin_TotalCache::ob_callback W3_Plugin_TotalCache::ob_callback calls w3tc_do_ob_callbacks() … Read more

Hosting a WordPress blog as a sub folder from a S3 website

You are using Cloudfront in front of S3, so in order to mix in 2 sources of content you need to on your blog.mycompany.com – add rewrites of blog/* -> /* so that your blog can handle blog.mycompany.com/blog/ urls well. add new blog.mycompany.com as an Origin in “Origins and Origin Groups” tab. add new “Behavior” … Read more

How to run WordPress across 2 VMs for high availability

The Bad News: The core open source base of WordPress does make quite a few assumptions about being run on a single server (wp-content, user uploads and media library to name a few) The Good News: Pretty much all cloud providers (including Azure) have abstractions that allow you to work around these design limitations. Fundamentally, … Read more