tombenner/wp-mvc

"Page not found" when using controller in frontend

Closed this issue · 1 comments

Hi,

I created an Ads controller. Here is my code:

class AdsController extends MvcPublicController {
public function show( ) {
$postarr = [
'post_type' => 'my_posts',
'post_status' => 'publish',
'post_title' => wp_strip_all_tags('My title'),
'post_content' => 'post-submission-content',
'post_excerpt' => 'post-submission-excerpt',
'meta_input' => 'meta_input',
];
$this->model->save_post($postarr);
echo 'Done.';
}
}

After that, in frontend, I typed: http://localhost/ads/show/ . Then wordpress displays the "Page Not Found".

How can I save a new post, then display the text "Done." in frontend?

Thank you for your help.

Nhat Nguyen

Be sure to flush the rewrite rules by going to Settings > Permalink and saving the settings. See "I am getting a 404 when I add a new route" on https://wordpress.org/plugins/wp-mvc/ in the FAQ section.