The WordPress REST API is one of my favourite features in WordPress. The ability to create custom endpoints for getting data and other facets of building in WordPress makes life so much easier.
Recently, while building a custom endpoint that allowed for some custom post type content to be searched, I encountered a snag.
register\_rest\_route( 'raw-queue/v1', '/queue/(?P[a-zA-Z0-9-]+)/(?P[\\d]+)/(?P[\\d]+)/(?P[a-zA-Z0-9-]+)/(?P([a-zA-Z])+)', array( 'methods' => 'GET', 'callback' => 'rest\_get\_news\_stories\_from\_category', 'permission\_callback' => '\_\_return\_true' ) ); For singular search terms, it worked well. However, once I searched for words like “basketball player”, I would get the dreaded 404 error.
The world might be attempting to get back to normal under the “new normal” label, but supply chains are still absolutely busted. As we head towards Christmas 2021, things show no sign of going back to normal in the world of logistics and supply chains.
Postal service providers like USPS and Australia post are struggling to deal with the large volumes of mail. USPS temporarily suspended postage to 21 countries, including Australia.
WordPress documentation is usually robust. However, recently I had a use case where I needed to query sites by custom meta values.
In WordPress 5.1, the WP_Site_Query was introduced to allow a faster way to query sites in a WordPress Multisite setup without using the old hack of needing to get all ID values using get_sites and then inside of a loop using switch_to_blog to query the sites and get values.
Out of the box, Advanced Custom Fields offers immense power but provides no functions to work with WordPress Multisite sites. Fortunately, WordPress makes it easy to work with multisite sites.
Throw the following function into your theme functions.php file and call it at will. Just provide the field name and site ID, the function will get your value from that site (if there is a value and field exists).
function get\_acf\_site\_option($field\_name, $site\_id) { switch\_to\_blog($site\_id); $value = get\_field($field\_name, 'option'); restore\_current\_blog(); return $value ? $value : null; }
What is the most efficient way to delete thousands of posts, custom post types, media attachments and other things in WordPress? The answer is: not through the admin panel.
If you have ever tried deleting a couple of hundred (or so) items from the WordPress admin panel before, then you would know if the request doesn’t timeout, you’ve won the WordPress lottery. And, if it does timeout, you have to keep spamming the refresh button until it works.
Filed under: super-specific use case with hints of generality for those wanting to write long-running PHP scripts.
For a little while now, I have been building a site with WordPress that consumes news content from the Associated Press news API and then stores the news content in WordPress.
My first iteration of the ingest engine with PHP worked quite well, but I encountered dreaded NGINX server timeouts and other issues.
Dates in Javascript have always been a PITA. It is one of the reasons that libraries like MomentJS reigned supreme for so long. Things are complicated, especially if you’re dealing with different timezones. Fortunately, working with simple DATETIME values has never really been a problem.
What prompted this post was that I am working with WordPress a lot at the moment, and all dates in WordPress are MySQL DATETIME formatted dates. Say you have a DATETIME value that looks like this: 2021-10-05 00:00:00 — you can use the Javascript Date object on this because it’s a valid date value.
If you thought the CD Projekt Red leak of Cyberpunk 2077 and other source code was bad, get a load of this latest leak.
Twitch just got hacked entirely, and the entirety of its source code, internal repositories, financial payout information and absolutely everything you can think of has been taken and put online in a 128GB torrent over on 4chan.
The anonymous individual or group says, “we have completely pwned them,” and let’s be honest, they’ve well and truly pwned Twitch here. What a massive leak. Some heads are going to roll over in the IT department over this. I am curious how this even happened.
If Windows 11 were a product with a slogan, it would be “same Windows, now 50% less ugly.” With Windows 11 finally, upon us, the question on the lips of many is: is it worth the upgrade?
Instead of starting from scratch, Microsoft took Windows 10 (which was already quite good), pulled some levers, put some finesse on the UI and modernised a few parts of the 35-year-old operating system (which was starting to show its age).
There is a Javascript library for almost anything. But sometimes, it’s good to code your solutions to specific problems where the resulting code will be lighter, and you will feel more rewarded as a result.
When it comes to infinite scrolling in Javascript, many examples, you will find online relate to scrolling the main window (which is a common thing). But what if you have an overflowing DIV that you want to add infinite scrolling on? The logic is the same.