I have to post data by AJAX in wordpress to another Website

This will not work due to the “same-origin policy” unless that server you are trying to reach specifically allows these type of requests with something like Access-Control-Allow-Origin: *. You can read the documentation on MDN in order to get more information about this topic. From my tests, the server will also need another header configured … Read more

Why aren’t tags and categories added in post request to WP Rest API

You are using name in your terms. In default, try to use the existing term id ( in your case, cat ID and tag ID ). If you see https://plugins.trac.wordpress.org/browser/rest-api/trunk/lib/endpoints/class-wp-rest-posts-controller.php#L918 they will handle your term with sanitize them into non-negative integer using absint. I hope this help. Here example code to hook rest_insert_{$this->post_type} to create … Read more

Develop REST API using WordPress for Android app [closed]

Hopefully someone will extend on my answer…. The critical part of the rest API that is already in core is the registration and routing of endpoints which should look like (taken from http://v2.wp-api.org/extending/adding/) `/** * Grab latest post title by an author! * * @param array $data Options for the function. * @return string|null Post … Read more

How to avoid loading wp-load.php from external php scripts?

Pretty much wp-load.php is the only way to go. I don’t think there is really another way to load the WordPress functions safely… You can account for path variations by recursively including it from any file where you need it though… eg. function file_find_require($file,$folder=null) { if ($folder === null) {$folder = dirname(__FILE__);} $path = $folder.DIRECTORY_SEPARATOR.$file; … Read more

Adding rest api endpoints to an old theme

WordPress REST API has nothing directly to do with the theme, REST API is in the WordPress core, and any plugin and theme can be made to support it. Normal WordPress themes don’t use REST API: it is relatively new part of the WordPress, and so far, very few themes are made to use REST … Read more

How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?

If you know the existing callback and priority you can just remove the filters and then add again at a different priority: remove_filter( ‘the_content’, ‘convert_smilies’, 20 ); add_filter( ‘the_content’, ‘convert_smilies’, 30 ); remove_filter( ‘the_content’, ‘capital_P_dangit’, 11 ); add_filter( ‘the_content’, ‘capital_P_dangit’, 20 );

Implementing an AJAX POST API call in wordpress

You got the error 400 Bad Request because the Content-Type header is application/json: $.ajax({ headers:{ “Content-Type”:”application/json” }, data: { … }, … }); And when the request content is a JSON string, the $_REQUEST[‘action’] which WordPress uses to identify the proper AJAX action (which is foo in your code) is not available (i.e. it’s a … Read more

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