我正在使用get_permalink($this->get_pageid())
获取网页网址。
我的永久链接可以作为样本帖子启用。它应为example.com/forum
但显示example.com/login
答案 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
当你在循环之外时。希望这会有所帮助。