• Manish

    (@manishrestha529)


    Hi there,
    I’ve been trying to develop large scale application in wordpress. Been through several plugin development best practices. And finally I’ve been reading the documentation of https://wpmvc.org/

    I pretty much understood its automatic (mvc) code generation tools. Its default controller functions index() & show() works pretty well.

    But, when I tried to add a custom_action(), thats where I got stuck.

    class DemoController extends MvcPublicController {
        public function hello(){
            print_r($this->params);
            die();
        }
    }

    above function hello() is only accessible by below URL:
    domain.com/demo/hello/{num}

    but can’t be accessed via:
    domain.com/demo/hello

    Do I need to write any custom route to make this work? Or, am I doing anything wrong?

    • This topic was modified 8 years, 6 months ago by Manish.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Manish

    (@manishrestha529)

    Sorry, my bad, it works ??

    But, yet, I need to deactivate/reactivate the plugin to make my function work as a route. Each time I add a new function.

    • This reply was modified 8 years, 6 months ago by Manish.

    You don’t need to deactivate/reactivate each time.

    From the FAQ:

    I am getting a 404 when I add a new route

    You need to go to Settings > Permalinks and click “save”. This flushes the WordPress rewrite rules. For performance reasons, the rewrite rules are only flushed either when the plugin is activated or when the Permalinks are saved. So, if you are developing with the plugin activated and adding controller routes as you go, you need to use this approach to flush the rewrite rules and use your new URL endpoints.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Working with custom routes in wp-mvc plugin’ is closed to new replies.