Object of class WP_Query could not be converted to int inside shortcode

I rewrote the function based on a few other posts I have seen online and now have the following code which works without any errors. I am still open to any further suggestions on the best way to streamline this code even further it it can be. Thanks again function downloads_shortcode($atts){ extract(shortcode_atts(array( ‘download_type’ => ” … Read more

How do I create a state of “don’t assign anything to variable” if WP_Error throws an error?

Looks like the line giving you the error is rather this one $data = json_decode( $this->get_json(), true); Like this (untested) it should work: private function get_data() { /** * Ingests the data from get_json() then converts / decodes into an array. */ $json = $this->get_json(); if (is_wp_error($json)) { return new WP_Error( ‘invalid-data’, esc_html__( ‘Something is … Read more

WP_Error could not be converted to string

There are few problems with your code. First of all, let’s see at wpmu_create_blog function: wpmu_create_blog( string $domain, string $path, string $title, int $user_id, array $meta = array(), int $network_id = 1 ) So you use it incorrectly. It’s 5th argument is $meta and you put $network_id in there… Another problem is that this function … Read more

To stylize WP_Error messages or not?

Personally I prefer to put all errors in a debug.log file using error_log and it would be readable enough as it includes break lines automatically. I think not all the errors should be visible for clients. In case that I need to show an error to the user, I check the error type and I … Read more