[英]Wordpress - get_permalink to return page_id instead of slug in %postname% permalink setting
So, I have wordpress site with http://example.com/%postname%/
in permalink setting. 因此,我在永久链接设置中具有
http://example.com/%postname%/
wordpress网站。
I want to echo get_permalink()
, which showing http://example.com/?page_id=xx
result 我想
echo get_permalink()
,它显示http://example.com/?page_id=xx
结果
but when I did echo get_permalink()
, it's return http://example.com/some-slug/
. 但是当我
echo get_permalink()
,它返回http://example.com/some-slug/
。 I know it's not an error because the permalink setting is %postname%. 我知道这不是错误,因为永久链接设置为%postname%。
I want to use it like this : 我想这样使用它:
echo '<a href="'. get_permalink() .'&get_weather='. $weather .'"></a>';
to make link result like this : 使链接结果是这样的:
<a href="http://example.com/?page_id=1&get_weather=rain"></a>
instead of this result: 而不是这个结果:
<a href="http://example.com/some-slug/&get_weather=rain"></a>
So, is it possible to get result of http://example.com/?page_id=xx
while echo
-ing get_permalink()
with %postname% (or other permalink setting option) as the permalink setting? 那么,是否可以在将%postname%(或其他永久链接设置选项)作为永久链接设置进行
echo
-ing get_permalink()
同时获取http://example.com/?page_id=xx
结果? please explain how 请解释一下
Thanks. 谢谢。
Just create the url manually 只需手动创建网址
<?php
$url = add_query_arg( array('page_id' => get_the_ID(), 'get_weather' => 'rain'), home_url('/') );
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.