[英]Result of get_permalink(0);
I'm new to wordpress and I'm following a tutorial right now but I don't understand wordpresses behaviour. 我是wordpress的新手,现在正在学习教程,但我不了解wordpress的行为。 I'm trying to change the title of a sidebar which lists the parentpage and it's childpages, this works fine but I don't understand why
$parentID = wp_get_post_parent_id(get_the_ID()); echo get_permalink($parentID);
我正在尝试更改侧栏的标题,该侧栏列出了父页面及其子页面,虽然工作正常,但我不明白为什么
$parentID = wp_get_post_parent_id(get_the_ID()); echo get_permalink($parentID);
$parentID = wp_get_post_parent_id(get_the_ID()); echo get_permalink($parentID);
works even on the parent page, I echoed the result on the parent page and it returns 0 since the parent page doesnt have a parent, so why does this still work? 即使在父页面上也可以工作,我在父页面上回显了结果,并且由于父页面没有父对象而返回0,为什么这仍然起作用? Why does
get_permalink(0);
为什么
get_permalink(0);
get me to the parent page if I press the button? 如果按下按钮,可以将我带到父页面?
get_permalink()is the function that gives you the link to the post/page inside the loop you are currently. get_permalink()是用于为您提供当前循环内的帖子/页面链接的函数。 Since you are not having parent page for the current page get_permalink is not able to get you to the parent page as nothing exist so in this case it will rediret you to the same page.
由于您没有当前页面的父页面,因此get_permalink无法将您带到父页面,因为不存在任何页面,因此在这种情况下,它将重新引导您到同一页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.