• Resolved justalillost

    (@justalillost)


    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..

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Depends what plugin you’re using to generate shortlinks.

    Thread Starter justalillost

    (@justalillost)

    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)

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    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:

    <?php
    
    /*
    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).

    Thread Starter justalillost

    (@justalillost)

    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…)

    Thanks!

    Thread Starter justalillost

    (@justalillost)

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Easy access to shortlinks’ is closed to new replies.