Images are displaying as blank images

You should generate the attachment metadata such as width and height — and file path, and also thumbnails, after you created the attachment: Using wp_generate_attachment_metadata(): $attach_id = wp_insert_attachment( $attachment, $filename ); if ( $attach_id ) { require_once ABSPATH . ‘wp-admin/includes/image.php’; $metadata = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $metadata ); } Using wp_maybe_generate_attachment_metadata(): $attach_id = … Read more

REST API and filtering by meta value

Add a third parameter in the get_post_meta() function as true, that will return the single value of the current post meta, if you don’t set it it will return an array of the values. What is happening now is that internally the query is trying to compare the meta_value with an array instead of a … Read more

I can’t post comment via REST API

I do not recommend doing this. It’s better if you authenticate your users, but you can make an api endpoint that posts a comment like this: add_action(‘rest_api_init’, function () { register_rest_route( ‘api’, ‘api_post_comment’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘api_post_comment’, ) ); }); function api_post_comment() { wp_insert_comment([ ‘comment_approved’ => 0, ‘comment_author’ => ‘test’, ‘comment_author_email’ => … Read more

Custom API plugin to execute 3rd party API to retrieve data

If you need to pass username and password for Basic Auth you need to send that in headers e.g. $headers = array(‘Authorization’ => ‘Basic ‘ . base64_encode( YOUR_USERNAME . ‘:’ . YOUR_PASSWORD ); $response = wp_remote_post( $url, array( ‘method’ => ‘POST’, ‘timeout’ => 45, ‘headers’ => $headers ) ); If you need to pass username … Read more

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