Detect 404 before headers are sent

Use a later action hook You cannot use Conditional Tags before the posts_selection hook has run (as per the codex), which happens right after pre_get_posts and quite a bit after init. Hence, would it not be easier to set the cookie at a later stage of the request, rather than attempting to detect the 404 … Read more

Changing Site Address (URL) causes 404

Go to phpMyAdmin and select the database for the website. Go to the “wp_options” table and edit the first option (option_name: siteurl) from “http://www.example.com/wordpress” to “http://www.example.com/somethingelse“. In the same “wp_options” table, look for “option_name: home” and change the URL there too. Now, rename your current .htaccess file to .htaccess_old and create a new blank .htaccess … Read more

wp_remote_get() not retrieving pages properly

The HTTP request sent by wp_remote_get() is different from the one that a browser sends. E.g the user-agent is different (see documentation). Some websites respond differently based on this. The second argument of wp_remote_get() allows one to alter the request. Websites might also respond differently depending on the IP or the number of requests received … Read more

WordPress REST API 404

I commented this, for my situation: I have this same issue. I’m on an Ubuntu-server, but I’ve simply pointed my host-file to point to the IP. I must admit I’m not 100% sure how the restful API works, if that has any effect or not. I’m on WP version 4.9.8, – and have the problem … Read more

Pagination shows 404 after a certain number of pages

The problem is that WordPress is executing the main query before your custom query (and the main query is based on the default post type only). You can intercept the main query, modify it, and then use it like so function add_blog_post_to_query( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘post_type’, array(‘post’, … Read more

REST API: No route was found matching the URL and request method

It’s because of how you’ve defined the accepted methods: ‘methods’ => ‘\WP_REST_Server::CREATABLE ‘, You shouldn’t have quotes around it. WP_REST_Server::CREATABLE is a string that equals ‘POST’, but by putting quotes around it you’re literally setting the method as ‘\WP_REST_Server::CREATABLE’, which is not a valid HTTP method. You can see this in the response to the … Read more

Turning Broken URLs Into Search Terms?

You can try a plugin to do this: http://wordpress.org/extend/plugins/smart-404/ Reads the page URL and tries to find a page/post that it might match and redirect to it. Found out about this plugin from: http://www.aebeta.com/web-hosting/seo/7-seo-friendly-404-plugin-for-wordpress.html

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