Just like Facebook and other PHP based websites you can also enable .PHP extension in your WordPress site pages. ALl you would be needing to do is install and activate .PHP on PAGES plugin and you are done.
After activation the plugin automatically adds .PHP extension in page permalinks structure. Alternatively, you can add the following code in your theme’s function.php file:
add_action('init', 'PHP_page_permalink', -1);
register_activation_hook(__FILE__, 'active');
register_deactivation_hook(__FILE__, 'deactive');
function PHP_page_permalink() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.php';
}
}
add_filter('user_trailingslashit', 'no_page_slash',66,2);
function no_page_slash($string, $type){
global $wp_rewrite;
if ($wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page'){
return untrailingslashit($string);
}else{
return $string;
}
}
function active() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.php';
}
$wp_rewrite->flush_rules();
}
function deactive() {
global $wp_rewrite;
$wp_rewrite->page_structure = str_replace(".html","",$wp_rewrite->page_structure);
$wp_rewrite->flush_rules();
}
?>