Assuming you have a page with the slug “teaching-portal”, this plugin adds a rewrite rule for that page that allows one part to be added after it in the URL, what you refer to as “mygetdata”. I’ve called it “lesson”.
<?php
/**
* Plugin Name: Custom PHP app on teaching-portal page
* Plugin URI: http://wordpress.stackexchange.com/questions/75991
*/
// Flush rewrite rules on plugin activation
register_activation_hook(__FILE__, 'wpse75991_activate');
function wpse75991_activate()
{
wpse75991_add_rewrite_rule();
flush_rewrite_rules();
}
// Flush rewrite rules on plugin deactivation
register_deactivation_hook(__FILE__, 'wpse75991_deactivate');
function wpse75991_deactivate()
{
flush_rewrite_rules();
}
// Add a custom rewrite rule for the teaching portal section
add_action('init', 'wpse75991_add_rewrite_rule');
function wpse75991_add_rewrite_rule()
{
$pagename="teaching-portal"; // Slug
add_rewrite_rule(
$pagename.'/?([^/]*+)',
'index.php?pagename=".$pagename."&lesson=$matches[1]',
'top'
);
}
// Register the custom query var so WP recognizes it
add_filter('query_vars', 'wpse75991_add_query_var');
function wpse75991_add_query_var($vars)
{
$vars[] = 'lesson';
return $vars;
}
With this plugin activated you should be able to access the lesson variable in your page template. Here’s a quick example:
$lesson = get_query_var('lesson');
if (empty($lesson))
{
// Show all lessons
}
else
{
// Show a single lesson
var_dump($lesson);
}
Also see the Rewrite API in the codex.