This wordpress function class code can be used to create virtual on the fly pages – note they won’t show up by default on widgets or in menues (they only exist when physically called via slug url), but can be custom linked. Possible to create links to them using header / footer filters/hooks. Also ideal if you want dynamic content displayed.

Replace the following with page urls (slug), title and contents..

‘slug’ => ”,
‘post_title’ => ”,
‘post_content’ => ”

if (!class_exists('wp_virtual_page_setup')){
    class wp_virtual_page_setup
    {

        public $slug ='';
        public $args = array();

        function __construct($args){
            $this->args = $args;
            $this->slug = $args['slug'];
            add_filter('the_posts',array($this,'virtual_page'));
        }

        public function virtual_page($posts){
            global $wp,$wp_query;
            $page_slug = $this->slug;

            if(count($posts) == 0 && (strtolower($wp->request) == $page_slug || $wp->query_vars['page_id'] == $page_slug)){

                //virtual page
                $post = new stdClass;
                $post->post_author = 1;
                $post->post_name = $page_slug;
                $post->guid = get_bloginfo('wpurl' . '/' . $page_slug);
                $post->post_title = 'page title';
                //put your custom content here
                $post->post_content = "Fake Content";
                //just needs to be a number - negatives are fine
                $post->ID = -42;
                $post->post_status = 'static';
                $post->comment_status = 'closed';
                $post->ping_status = 'closed';
                $post->comment_count = 0;
                $post->post_date = current_time('mysql');
                $post->post_date_gmt = current_time('mysql',1);
                $post = (object) array_merge((array) $post, (array) $this->args);
                $posts = NULL;
                $posts[] = $post;

                $wp_query->is_page = true;
                $wp_query->is_singular = true;
                $wp_query->is_home = false;
                $wp_query->is_archive = false;
                $wp_query->is_category = false;
                unset($wp_query->query["error"]);
                $wp_query->query_vars["error"]="";
                $wp_query->is_404 = false;
            }

            return $posts;
        }
    }//end class
}//end if

$args = array(
        'slug' => '',
        'post_title' => '',
        'post_content' => ''
);
new wp_virtual_page_setup($args);