I would like to create a custom rewrite rule that will take the URL:
http://domain/submit-project/add
but display
http://domain/wp/wp-admin/post-new.php?post_type=project
Is there any way to do this? I am trying to add the rewrite rule so in my theme’s functions.php
add_action( 'init', 'add_custom_rules' );
function add_custom_rules() {
add_rewrite_rule(
"^submit-project/add",
"/wp/wp-admin/post-new.php?post_type=project",
"top");
}
I’ve tried flushing the rules, but this always seems to enter some kind of loop always going back to the ‘login’ page.
Edit
- The URL is actually just 404-ing now
- I should add that I do have a page with the slug
submit-project
and thus the URL:http://domain.com/submit-project
in case it matters. - I’ve installed the plugin Rewrite Rules Inspector and can’t seem to find my rule in there.
In general, it is possible, but you need to define
ADMIN_COOKIE_PATH
in yourwp-config.php
to the value/
which might cause security issues.First of all define this rewrite rules in your .htaccess right before the rewrite rule of wordpress:
Now you need to define the constant in the
wp-config.php
I recommend not to use this on a productive site. Consider to offer a special input formular in the frontend using shortcodes or something less invasive than the shown example.