WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Easy access to shortlinks (6 posts)

  1. justalillost
    Member
    Posted 2 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..

    Thanks!

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

  3. justalillost
    Member
    Posted 2 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:

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

  5. justalillost
    Member
    Posted 2 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...)

    Thanks!

  6. justalillost
    Member
    Posted 2 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

Tags