How do I programmatically generate a 404?

function generate_404_somehow() { global $wp_query; $wp_query->is_404 = true; } add_action(‘wp’,’generate_404_somehow’); Of course, that will send all of you page to the 404 template. I don’t know what the conditions are that this should fire or not fire. Or to be more cautious (see comments) … function generate_404_somehow() { global $wp_query; $wp_query->set_404(); } add_action(‘wp’,’generate_404_somehow’);

Redirect Localhost wordpress site to dashboard

It sounds like the site & home URLs are not set correctly. You can set these in wp-admin from the Settings screen, although it sounds like you may not be able to get in there right now, so a workaround is to do the following: Edit your wp-config.php file Search to see if WP_HOME or … Read more

Disable ONLY URL auto complete, not the whole canonical URL system

Updated Answer (2020-10-29): The solution has changed with WordPress 5.5. Keeping the old answer for reference below. Short version: Get my pluign from here: https://wordpress.org/plugins/disable-url-autocorrect-guessing/ Long Version: With WordPress 5.5, you can control more precisely if/how the guessing should work. Refer to https://make.wordpress.org/core/2020/06/26/wordpress-5-5-better-fine-grained-control-of-redirect_guess_404_permalink/ for more information. To completely disable guessing, use this code: add_filter( ‘do_redirect_guess_404_permalink’, … Read more