Where is the best part to hijack or catch a potential 404

It’s not possible to catch a non–match to template in WP because it will always match some template. The very last template it will fall back to will simply be index.php, the most generic one in template hierarchy. In general the appropriate hook for such logic is typically template_redirect in template-loader.php. At this point the … Read more

removed index.php now all pages 404

If you want to remove the index.php from your URL structure, then using this rewrite rule (assuming you’re using Apache, from your question) in your .htaccess will help. # BEGIN WordPress RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress Then, flush permalinks by either using WP-CLI … Read more

Result of Custom WP_Query appears on 404 Page (but result are found!)

I found out its because I used a Input with name=”name” which caused this issue. I believe the name ‘name’ is a keyword in wordpress/php. I replaced the ‘name’ to ‘personname’ then it works as charm. … <input name=”personname” type=”text” value=”” /> … $_POST[‘gsdname’] // multiple time in my code … Best regards Floh

category/category_name pagination 404 error

In the template used for category archives you should have no use for new WP_Query. For all the main templates that WordPress loads itself for post archives, WordPress has already queried the correct posts, so you don’t need to query them again with WP_Query. For these templates, it’s the template’s job just to display those … Read more

Where does the 404 redirection happen?

Based on your comments, I think I get what you’re saying. However, you don’t want to redirect on a 404, since it defeats the object of the ‘Not Found’ header. However, you can filter the 404 template path and pass back your own; function __custom_404( $standard_404 ) { if ( something_is_true() ) return ‘/absolute/path/to/custom.php’; return … Read more

Some plugins adding full server path after url (with custom wp-content folder)

Given that the js location is determined as follows: $js_location = WPSEO_URL . ‘js/wp-seo-admin-global.js’ where: WPSEO_URL = WP_PLUGIN_URL . “https://wordpress.stackexchange.com/” . <WP_SEO_PLUGIN_PATH> . “https://wordpress.stackexchange.com/” I suspect the problem lies with the derivation of <WP_SEO_PLUGIN_PATH>. This value is determined by the code in the function plugins_url() found in wp-includes\link-template.php If you debug that function, it may … Read more