The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] Easy access to shortlinks (6 posts)

  1. justalillost
    Posted 4 years ago #

    In the .com version, we could hover over the menu bar at the top to access the shortlink for the particular page.

    Is there a plugin or setting that can be activated to bring that back? It's annoying to have to "edit" the post to get to the shortlink..


  2. Depends what plugin you're using to generate shortlinks.

  3. justalillost
    Posted 4 years ago #

    I've just got the jetpack one, that lets me get the shortlink in the editing page.

    Is there a good recommended one that I - or others - can easily get on each page? (like the .com version)

  4. Well different plugins give different short URLs ;) Like I use Yourls, and my theme shows me the short URL.

    However to add whatever WP thinks the short URL is to your toolbar, you need a function... I tested it briefly and it works. Make a file called my-shorturl.php and put this in it:

    Plugin Name: Short URL Toolbar
    Description: Show 'shortURL' in the toolbar bar.
    Version: 1
    Author: Me
    function show_short_url_toolbar ( $wp_admin_bar) {
        global $wp_admin_bar;
        if (is_singular() ) {
            $short_url = wp_get_shortlink();
            $wp_admin_bar->add_menu(array( 'id' => 'my-shorturl', 'title' => __('ShortURL'), 'href' => '#' ));
            $wp_admin_bar->add_menu(array( 'id' => 'my-shorturl-slug', 'parent' => 'my-shorturl', 'title' => $short_url, 'href' => $short_url ));
    add_action ('admin_bar_menu', 'show_short_url_toolbar', 90);

    Then put that file in the mu-plugins folder on your server (if you don't have one, make one, it's the same level as your plugins and themes folders).

  5. justalillost
    Posted 4 years ago #

    Thanks! I tried putting the mu-plugins.php into a mu-plugins folder both into the same level as plugins & themes, AND into the plugins folder and both didn't seem to work.

    Sorry for the seemingly stupid question.... but if, for example, my plugins folder and themes folder is under /wp-content/ , I should also put the mu-plugins folder there? (It didn't seem to work...)


  6. justalillost
    Posted 4 years ago #

    Ah, scratch that... just tested it out a bit more and got it working. Thanks again! :)

Topic Closed

This topic has been closed to new replies.

About this Topic