How do I fetch each row as an associative array using $wpdb?

wpdb‘s get_results method takes an optional second argument that lets you specify how the data is returned. The default return is an object. But you can also set it to… OBJECT – result will be output as a numerically indexed array of row objects. OBJECT_K – result will be output as an associative array of … Read more

Convert all images on S3 to webp format

You also need to update the database so that the converted images are referenced properly instead of the old ones. If you delete the old format images without updating the database, you will break the site as none of the old images will be found. The plugin “WebP express” will help with this, but I … Read more

Custom function wordpress php

You must be thinking something like this: In this URL: https://myawesomewebsite.com/page?custom_id=456 function check_parameter_in_url() { if ( isset( $_GET[‘custom_id’] ) { //do something } }

Error Function is_tax was called incorrectly

Somewhere in the codebase, the function or method is_tax() is being called before WordPress knows what content is being requested. Using a plugin like Query Monitor will help determine it’s source. There may also be a stack trace in wp-content/debug.log (if WordPress is setup with debug constants). This would not be a symptom of lazy … Read more

How to force a Custom Post Type template by filename

you likely need to do a flush re-write. go to settings/permalinks in the dashboard and click save. You’ll be good to go. In the future you can add this directly to your CPT plugin. I would suggest getting a bit more creative with your naming though so you don’t have conflicts later.

MariaDB version not recognised

As discussed in comments, the problem was a missing prce2 package which meant preg_match(), used by $wpdb->db_version() to parse the MySQL version number out of SELECT VERSION(), didn’t work. Solved by sudo yum install pcre2

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)