What is the difference between get_page_link and get_permalink functions?

Both functions return permalink to the post or page by it's ID. What are the differences and which of these functions should I use in which cases?

Topic comparison functions Wordpress

Category Web


In my opinion get_page_link is for displaying the link and get_permalink is not for displaying the link.

WordPress Codex says: get_permalink: It does NOT display the permalink.


When i explored the WordPress core for this answer i found that get_permalink() function internally calls get_page_link() function for getting permalink of page and it calls get_post_permalink() function to get permalink of post.

Therefore either you use get_permalink() function or get_page_link() function, you will get same result.

The difference between these two is get_page_link() function handles page_on_front page set in back end whereas get_post_permalink() function do not consider it.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.