Hi,
I have a WordPress plugin and its have a view page for front end user.Now this view page link is like:
localhost/wordpress/wp-content/plugins/my_plug/plug_page.php
Now i want to create a virtual page for this page and want to page url like
localhost/wordpress/plug_page
After Googling I got some examples.I was following this tutorial:
wordpress-virtual page
Here is my code snippet for this in my plugin page:
add_action('init', 'action_init_redirect');
function action_init_redirect() {
add_rewrite_rule('plug_page/?', 'index.php?my_para=plug_page', 'top');
}
add_filter('query_vars', 'filter_query_vars');
function filter_query_vars($query_vars) {
$query_vars[] = 'my_para';
return $query_vars;
}
add_action('parse_request', 'action_parse_request');
function action_parse_request(&$wp) {
if (array_key_exists('my_para', $wp->query_vars)) {
get_header();
echo "I will replace it by my plug_php file";
get_sidebar();
get_footer();
exit;
}
}
Is there anything that i missed?? I have tried it my localhost.I saw in terminal it says
File does not exists localhost/wordpress/plug_page
Actually this code running good.I have to called this page like this:
localhost/wordpress/?mypara=whatever