WordPress Link Functions

About This Index
This page is the WordPress Link Functions index. Each row links to a full guide with syntax, three examples, and FAQs.
Learn the big picture on WordPress Link Functions. Use this page when you need one function, such as the_permalink(), home_url(), or edit_post_link().
Functions that start with the_ print a value. Functions that start with get_ return it, so escape it with esc_url() when you print it. home_url() is the front of your site, and site_url() is where WordPress is installed.
How to Call a Link Function
Most link functions are used in theme templates. Here is one that prints and one that returns.
<?php
// Prints the URL (already escaped).
?>
<a href="<?php the_permalink(); ?>">Read more</a>
<?php
// Returns the URL. Escape it when you print it.
$url = get_permalink();
echo '<a href="' . esc_url( $url ) . '">Read more</a>'; WordPress Link Functions Table
All function guides in this WordPress links series (25 tutorials). Start with the_permalink() and home_url().
Permalink & Post URLs
6 functionsGet or print the address of a post, page, or attachment.
| Function | Description | Tutorial |
|---|---|---|
the_permalink() | Print the permalink of the current post, already escaped. | Read guide |
get_permalink() | Return the permalink of a post, page, or other post type. | Read guide |
get_post_permalink() | Return the permalink of a post, built for custom post types. | Read guide |
get_page_link() | Return the permalink of a page. | Read guide |
get_attachment_link() | Return the URL of an attachment page (image or file page). | Read guide |
permalink_anchor() | Print an empty anchor tag with an ID for the current post, so you can jump to it. | Read guide |
Site & Home URLs
6 functionsBuild links to your front page, your WordPress install, and wp-admin.
| Function | Description | Tutorial |
|---|---|---|
home_url() | Return the home URL of the current site, with an optional path. | Read guide |
get_home_url() | Return the home URL of a site, with an optional path. Can pick a site on multisite. | Read guide |
site_url() | Return the site URL of the current site (where WordPress is installed), with an optional path. | Read guide |
get_site_url() | Return the site URL (where WordPress is installed) for a site, with an optional path. | Read guide |
get_admin_url() | Return the admin area URL for a site, with an optional path. | Read guide |
user_trailingslashit() | Add or remove the trailing slash of a URL to match your permalink setting. | Read guide |
Search, Feeds & Privacy
5 functionsSearch result links, feed links, and the Privacy Policy link.
| Function | Description | Tutorial |
|---|---|---|
get_search_link() | Return the URL of the search results page for a search term. | Read guide |
get_search_query() | Return the current search word, escaped by default. | Read guide |
the_feed_link() | Print a link to a site feed (RSS or Atom) with the text you choose. | Read guide |
the_privacy_policy_link() | Print the Privacy Policy link, if a policy page is set. | Read guide |
get_the_privacy_policy_link() | Return the Privacy Policy link as HTML, or an empty string if none is set. | Read guide |
Edit & Admin Links
6 functionsLinks that take logged-in users to the edit or delete screens.
| Function | Description | Tutorial |
|---|---|---|
edit_post_link() | Print an Edit link for a post or page when the current user can edit it. | Read guide |
get_edit_post_link() | Return the admin URL for editing a post, or null if the user cannot edit it. | Read guide |
get_delete_post_link() | Return the URL that moves a post to the Trash, or deletes it for good. | Read guide |
edit_comment_link() | Print an edit link for the current comment if the user can edit it. | Read guide |
edit_tag_link() | Print an edit link for a tag if the user can edit it. | Read guide |
edit_bookmark_link() | Print an edit link for a bookmark (link manager entry) if the user can edit links. | Read guide |
Shortlinks
2 functionsShort post addresses sent in the head and in HTTP headers.
| Function | Description | Tutorial |
|---|---|---|
wp_shortlink_wp_head() | Print a shortlink link tag inside the page head. | Read guide |
wp_shortlink_header() | Send a Link: shortlink HTTP header for the current page. | Read guide |
Frequently Asked Questions
Start with the_permalink()
Print the permalink of the current post, already escaped.
12 people found this page helpful
