在函数中添加以下自定义函数。获取主题的php文件page url without the clean urls
function get_page_custom_link() {
global $post;
$link = \'\';
if ( \'page\' == get_option( \'show_on_front\' ) && $post->ID == get_option( \'page_on_front\' ) )
$link = home_url(\'/\');
else
$link = home_url( \'?page_id=\' . $post->ID );
return $link;
}
并在模板中调用它,如下所示
<?php echo get_page_custom_link(); ?>
Note : It will not work for other urls( attachments, tags, taxonomy, post etc.)