Function and usage of get_shortcut_link() in wordpress


Answers ( 1 )


    The get_shortcut_link() function in WordPress is specifically designed for retrieving the "Press This" bookmarklet link. Here's a detailed explanation and sample usage:

    Function Signature:

    get_shortcut_link(): string


    • Purpose: The primary function of get_shortcut_link() is to retrieve the URL for the "Press This" bookmarklet.
    • Press This Bookmarklet: This is a special tool in WordPress that allows users to quickly and easily post to their blog without having to navigate to the WordPress dashboard. It's particularly useful for sharing content from other web pages.


    • Type: string
    • Description: The function returns a string that is the URL of the "Press This" bookmarklet. This URL can be added to the bookmarks bar of a browser, enabling the user to post to their WordPress site from anywhere on the web.

    Sample Usage:

    Basic Usage:

    $press_this_link = get_shortcut_link();
    // Echo the link - can be used in a template file
    echo '<a href="' . esc_url( $press_this_link ) . '">Press This</a>';

    In this example, get_shortcut_link() is called to retrieve the bookmarklet URL. The URL is then used to create a hyperlink. When a user clicks this link, the "Press This" interface will be opened, allowing them to post to their WordPress blog.

    Practical Implementation:

    • Template Files: This function is particularly useful in WordPress template files where you might want to provide a quick-access link for posting to the blog.
    • Custom Admin Pages: If you're creating a custom admin page or dashboard widget, you can include this link to enhance user experience by providing an easy way to post content.

    Important Notes:

    • User Role and Capabilities: Ensure that the users who have access to this link have the appropriate permissions to post content on your WordPress site.
    • Security: Always use esc_url() when echoing the URL to prevent potential security risks.

    By using get_shortcut_link(), WordPress theme and plugin developers can provide a more streamlined and efficient content posting experience for their users.

Leave an answer