Rugo
Rugo

Reputation: 383

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. 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); 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? Why does get_permalink(0); get me to the parent page if I press the button?

Upvotes: 0

Views: 59

Answers (1)

Pratikb.Simform
Pratikb.Simform

Reputation: 61

get_permalink()is the function that gives you the link to the post/page inside the loop you are currently. 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.

Upvotes: 1

Related Questions