Custom plugin with shortcode not working

add_shortcode(‘myCustomShortcode’, ‘this_particular_function’); As soon as I looked at my code this morning I realized I was trying to pass the function name ([this_particular_function]) as the shortcode, not the shortcode name ([myCustomShortcode]). I overlooked this SO many times yesterday trying to look for some complex answer! I am smacking my head on the desk. Everything works … Read more

getJSON response to PHP

After more reading and testing, i’ve realised that i misunderstood how AJAX works, therefore it was never gonna work the way i thought it would. For those who come across this, i hope this will help. In shortcode function i generated the api url with params specific to the page where shortcode is called. eg … Read more

Why am I getting an error when requiring a file in my plugin?

As the names suggest, plugin_dir_path() will get the filesystem path, while plugin_dir_url gets the URL. A file path looks something like this /var/www/html/wp-content/plugins/my-plugin/ and can be used by PHP to find a file on the server. A URL will look like https://www.example.com/wp-contents/plugins/my-plugin/ and is intended to be accessed over the web. If you attempt to … Read more

Uncaught Error: Cannot use object of type stdClass while showing the list using WP_List_Table

$this->items = $this->get_table_data(); If this line is triggering the error, then the reason is probably that items should be an array of arrays, not an array of stdClass objects. But you don’t need to change much, as get_results() does support returning arrays instead of objects (which is the default). Instead of $get_bl_list = $wpdb->get_results(“SELECT * … Read more

Rest Api WordPress

Check caching/plugins interference Try using: jQuery.ajax({ type: ‘POST’, url : obj_php.ajax_url_login, beforeSend: function (xhr) { xhr.setRequestHeader(‘X-WP-Nonce’, obj_php.nonce); }, Check that nonce is actually set correctly in the hidden form field and when submitting check the payload in dev console, make sure the key/value match i.e, nonce_check: e7chadas0d Lastly, double check you have it setup according … Read more

Authenticate + Authorize WP REST API request before built-in WP JSON Schema Payload Validation?

Alright, guess I figured it all out: Has WP Core been updated to do JSON Schema – based request argument validation automatically now? It seems that that’s the case, yes. If you provide a proper JSON schema, as shown in the example, when using register_rest_route, payload validation is executed automatically, without the provision of a … Read more

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