Roots Discourse

Admin rewrite rule not working as expected (I think?)

Hi I’m using a Trellis/Bedrock (not Sage) setup for my site. And I would like some custom rewrite rules for the admin area. But I can’t seem to get it to work. Does anyone here have any experience rewriting the admin urls?

I would like if a user goes to /wp/wp-admin/sorm-submissions they would end up at /wp/wp-admin/edit.php?post_type=form&page=form-submissions (but with the nice url kept, i.e. not a redirect, a rewrite). The destination is created using add_submenu_page() in the admin_menu menu hook. And that page works as expected.

This is my current (non functioning) attempt:

add_action('init', function () {
  add_rewrite_rule(
    '^wp/wp-admin/form-submissions$',
    'wp/wp-admin/edit.php?post_type=form&page=form-submissions',
    'top',
  );
});

Will I have to work with the nginx config to make this work properly on a trellis page?

Hey there! I don’t imagine this is a Trellis-specific issue? Are you able to get that same code working with a different webserver setup?

That might be correct. I will give it a go and see if I can make it work. But I went another way with my direct problem though. So not real issue right now :blush:

This topic was automatically closed after 42 days. New replies are no longer allowed.