I must create a frontend web page (and sub-pages) which is able to show customized knowledge that’s saved within the database however will not be a part of wordpress, it isn’t a submit or web page as such however API referred to as knowledge. I don’t need to use a brief code due to the necessity of sub-pages.
I’ve appeared on the following however do not appear to have the ability to make it work as required: Dynamic URL, not a bodily web page inside the database
What I want is to have for instance website.com/mypage/
however I are not looking for ‘mypage’ to exist within the backend.
I’ve achieved this with:
public perform mypage_rewrite_ext() {
international $wp_rewrite;
$plugin_url = plugins_url( 'mypage.php', __FILE__ );
$plugin_url = substr( $plugin_url, strlen( home_url() ) + 1 );
// The sample is prefixed with '^'
// The substitution is prefixed with the "dwelling root", not less than a '/'
// That is equal to appending it to `non_wp_rules`
$wp_rewrite->add_external_rule( 'mypage$', $plugin_url );
}
However I want my web page to nonetheless be inside WordPress as I want to make use of the header and footer.
I’ve tried the next from the above linked query, however this simply redirects to the house web page (even after re-saving permalinks):
public perform add_query_vars( $query_vars )
{
$query_vars[] = 'check';
return $query_vars;
}
public perform add_endpoint()
{
add_rewrite_rule('^mypage/?', 'index.php?__test=1', 'high');
flush_rewrite_rules(false); //// <---------- REMOVE THIS WHEN DONE
}
public perform sniff_requests($wp_query)
{
international $wp;
if(isset($wp->query_vars[ '__test' ])) {
add_filter('template_include', perform ($original_template) {
// change the default template to a google map template
return plugin_dir_path( __FILE__ ) . 'mypage.php';
});
}
}
Any concepts on 1) what I’m doing flawed and/or 2) how I can obtain this?