Wordpress get_permalink($ this-> get_pageid())显示错误的网址

时间:2012-11-30 08:29:49

标签: php wordpress

我正在使用get_permalink($this->get_pageid())获取网页网址。

我的永久链接可以作为样本帖子启用。它应为example.com/forum但显示example.com/login

1 个答案:

答案 0 :(得分:1)

你的问题不太清楚,因为get_pageid()不是wordpress'本机函数,你没有提供任何代码。反正...

实际上get_permalink()期望一个可选的id作为参数,它应该是一个整数,只有在循环外使用它时才需要这样做,所以请确保$this->get_pageid()返回一个整数值。举个例子,它应该是这样的

get_permalink(10) // 10 should be your page/post id

您也可以使用

get_permalink(get_page_by_title('Some Page')) // Some Page is page/post title

或者,您可以使用

global $post;
get_permalink($post->ID); // $post->ID will return the page/post id

当你在循环之外时。希望这会有所帮助。