Using WordPress ‘get_shortcut_link()’ PHP function

The get_shortcut_link() WordPress PHP function retrieves the Press This bookmarklet link.


Let’s say you want to get the Press This bookmarklet link and display it on a page. Here’s how you might do it:

$press_this_link = get_shortcut_link();
echo 'Press This: ' . $press_this_link;


  • This function does not have any parameters.

More Information

See WordPress Developer Resources: get_shortcut_link()

This function was introduced in WordPress 2.6.0 and there’s no deprecation information up until WordPress 5.8. It’s located in wp-includes/link-template.php.


Displaying the Press This link in a WordPress post or page

// Get the Press This link
$press_this_link = get_shortcut_link();

// Display the link
echo '<a href="' . $press_this_link . '">Press This</a>';

In this code, we are simply getting the Press This link and displaying it as a hyperlink in a WordPress post or page.

// Inside your widget display function
echo '<div class="widget-content">';
echo '<a href="' . get_shortcut_link() . '">Press This</a>';
echo '</div>';

Here, we are directly inserting the Press This link into a widget in the WordPress sidebar.

// Inside your menu creation function
$menu_item = array(
    'title' => 'Press This',
    'url' => get_shortcut_link()
wp_update_nav_menu_item($menu_id, 0, $menu_item);

In this example, we are creating a new menu item that includes the Press This link.

// Inside your footer.php file or footer action hook
echo '<footer>';
echo '<a href="' . get_shortcut_link() . '">Press This</a>';
echo '</footer>';

This time, we are adding the Press This link to the footer of the WordPress site.

// Inside your theme or plugin where you want to display the link
if(current_user_can('activate_plugins')) {
    echo '<a href="' . get_shortcut_link() . '">Press This</a>';

In this last example, we are checking if the current user is an admin, and if so, we display the Press This link.