saurabh
Forum Replies Created
-
Forum: Plugins
In reply to: [WP Custom HTML Page] Publish custom html page using wordpress post apiHello, while post request its giving following error in log:
2019/11/18 11:14:13 [error] 130878#130878: *6306 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Cannot use object of type WP_Post as array in /www/sandboxframework11_975/public/wp-content/plugins/wp-custom-html-pages/wp-custom-html-pages.php:298 Stack trace: #0 /www/sandboxframework11_975/public/wp-includes/rest-api/endpoints/class-wp-rest-controller.php(431): WPCHTMLP_update_api_post_meta_permalink('custom-article1', Object(WP_Post), 'html_permalink', Object(WP_REST_Request), 'wpchtmlp_page') #1 /www/sandboxframework11_975/public/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(602): WP_REST_Controller->update_additional_fields_for_object(Object(WP_Post), Object(WP_REST_Request)) #2 /www/sandboxframework11_975/public/wp-includes/rest-api/class-wp-rest-server.php(946): WP_REST_Posts_Controller->create_item(Object(WP_REST_Request)) #3 /www/sandboxframework11_975/public/wp-includes/rest-api/class-wp-rest-server.php(329): WP_REST_Server->dispatch(Object(WP_REST_Request)) #4 /www/sandboxframework11_975/public/wp-includes/rest-api.ph" while reading response header from upstream, client: 116.75.133.173, server: framework11.com, request: "POST /wp-json/wp/v2/wpchtmlp_page HTTP/1.0", upstream: "fastcgi://unix:/var/run/php7.3-fpm-sandboxframework11.sock:", host: "framework11.com", referrer: "http://localhost:4200/"following is the Line no 298 in plugin code –
return update_post_meta($object['id'], 'WPCHTMLP_page_meta_box', array('html_permalink', $value));Forum: Plugins
In reply to: [WP Custom HTML Page] Publish custom html page using wordpress post apiHello milos, Below is the error log.
<strong>Warning</strong>: Illegal string offset 'html_permalink' in <strong>/www/sandboxframework11_975/public/wp-content/plugins/wp-custom-html-pages/wp-custom-html-pages.php</strong> on line <strong>292</strong> <strong>Notice</strong>: Uninitialized string offset: 0 in <strong>/www/sandboxframework11_975/public/wp-content/plugins/wp-custom-html-pages/wp-custom-html-pages.php</strong> on line <strong>292</strong> <strong>Warning</strong>: Illegal string offset 'html_code' in <strong>/www/sandboxframework11_975/public/wp-content/plugins/wp-custom-html-pages/wp-custom-html-pages.php</strong> on line <strong>286</strong> <strong>Notice</strong>: Uninitialized string offset: 0 in <strong>/www/sandboxframework11_975/public/wp-content/plugins/wp-custom-html-pages/wp-custom-html-pages.php</strong> on line <strong>286</strong>Forum: Plugins
In reply to: [WP Custom HTML Page] Publish custom html page using wordpress post apiHello, I copy paste code from the link I am still getting error. If you tried same is it successfully done at your end?
I am using postman and angular to test api call.
Forum: Plugins
In reply to: [WP Custom HTML Page] Publish custom html page using wordpress post apiI have solved CORS error by putting header(“Access-Control-Allow-Origin: *”); at the top. but error 500 is still present.
Forum: Plugins
In reply to: [WP Custom HTML Page] Publish custom html page using wordpress post apihello, I put above code and changed keys content to html_code and slug to html_permalink in the request body. but now it’s giving error with status 500.
below is the error response:
{
“code”: “internal_server_error”,
“message”: “The site is experiencing technical difficulties.”,
“data”: {
“status”: 500
},
“additional_errors”: []
}and below is the error in console:
Access to XMLHttpRequest at https://example.com/wp-json/wp/v2/wpchtmlp_page from origin http://localhost:4200 has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Forum: Plugins
In reply to: [WP Custom HTML Page] Publish custom html page using wordpress post apiThanks Milos,
as you said i changed the code. now i am able to publish page through API but now the problem is i cant set custom html and custom permalink through API.following is the body of xhr request:
{
“title”: “example”,
“status”: “publish”,
“slug”: “this-is-permalink”,
“content”: `<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style type=”text/css”></style>
</head>
<body>
</body>
</html>
`
}