Hello,
I am encountering an issue when trying to access the REST API endpoint /wp-json/td-composer/save_post. The route returns a 404 error (“No route was found that matches the URL and request method”). However, I am able to access the namespace /wp-json/td-composer/, which suggests the namespace is registered, but the specific endpoint is not.
Here’s what I’ve already tried to resolve the issue:
1. Code Review
I checked the tdc_ajax.php file where the /save_post/ route is registered with the following code:
php
register_rest_route($namespace, '/save_post/', array(
'methods' => 'POST',
'callback' => array('tdc_ajax', 'on_ajax_save_post'),
'permission_callback' => '__return_true',
));
I tested replacing the callback with an anonymous function that returns a simple response, but the 404 error persists:
php
register_rest_route($namespace, '/save_post/', array(
'methods' => 'POST',
'callback' => function() {
return new WP_REST_Response('Route is working', 200);
},
'permission_callback' => '__return_true',
));
2. Server Permissions
I adjusted the server permissions to ensure:
Directories are set to 755.
Files are set to 644.
The wp-config.php file is secured with 600 permissions.
Ownership of files and directories is set correctly for the web server user (apache).
3. Permalink Rewriting
I resaved the permalink settings in Settings > Permalinks in WordPress, but it didn’t resolve the issue.
4. Cache and ModSecurity
Cleared all caching services (Cloudflare and any caching plugins).
Temporarily disabled ModSecurity to ensure it wasn’t blocking the REST requests.
5. PHP Extensions and Configuration
Verified that the necessary PHP extensions are active, including:
json
curl
mbstring
openssl
The PHP version is 7.4, which meets the requirements.
Increased the PHP limits in the php.ini configuration:
memory_limit = 256M
max_execution_time = 300
post_max_size = 64M
6. Plugin and Theme Conflicts
Tested with all other plugins disabled, leaving only the one registering the REST route.
Switched to the default Twenty Twenty-One theme to ensure there was no theme conflict, but the 404 error persists.
7. Error Logs
Checked the PHP and server (Apache) error logs but found no relevant messages related to the failure in registering the REST route.
8. Namespace Adjustments
The namespace is currently set to ‘td-composer’. I also tried adding a version (‘td-composer/v1’), but the issue remains the same.
9. Debugging Attempts
I added debug statements to ensure that the rest_api_init hook is being called. The debug message appears, confirming that the code is executing, but the /save_post/ endpoint is still not accessible.
After trying all these solutions, I am reaching out for assistance. Is there any specific issue with the Newspaper theme or the td-composer plugin that could be causing this failure to register the route?
Thank you in advance for your help. I look forward to your guidance.
Make sure you don’t have a security plugin running that disables the REST API with is security hole along with XML-RPC.
Probably not the issue, just a thought.
https://jetpack.com/blog/wordpress-rest-api/
Hello,
Thank you for the suggestion. I’ve checked, and I don’t have any security plugins disabling the REST API or XML-RPC. Additionally, I can access the /wp-json/td-composer endpoint without any issues, but the problem arises when trying to access internal endpoints like /wp-json/td-composer/save_post, which still returns a 404 error.
It seems the namespace is registered correctly, but the specific endpoints within it are not accessible.
I appreciate any further suggestions that might help resolve the issue.
Best regards,
Hi pivetesgames,
The first suggestion is to disable and delete the current tagDiv plugins and after that please go to Newspaper > plugins and reinstall the plugins from there. Then, the next step will be to set the theme requirements -https://forum.tagdiv.com/requirements-for-newspaper/ make sure that this code is set – https://i.imgur.com/m2Z6S9X.png
The next step will be to check the .htaccess file, this should have only the default WordPress code, after that re-save the permalinks and also please try with plain permalinks.
Thank you!
Hi pivetesgames,
In this situation please make a full backup for the website and please contact us via email at contact@tagdiv.com and please provide wp-admin and cPanel access. We’ll check it as soon as possible. Also include the link of this topic in email to can identify you faster.
Thank you!