WordPress.org

Ready to get started?Download WordPress

Forums

URL Shortener
[resolved] Insert plugin output in WP template file (5 posts)

  1. Publishink
    Member
    Posted 2 years ago #

    Thank you for this plugin.

    Is there a way to have more control over where the short url is output in a post? Currently, the output appears at the end of the post content, but I would like to mix the short url in with the post metadata.

    You can do this with the bit.ly linker plugin, but I would prefer to use your plugin with my goo.gl api key. With bit.ly linker, you can use the code below in your template:

    <?php bitly(); ?>

    Thanks in advance

    http://wordpress.org/extend/plugins/url-shortener/

  2. Gerald
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Publishink,

    to display, you can use the WordPress template tag:

    <?php the_shortlink(); ?>

  3. Publishink
    Member
    Posted 2 years ago #

    Thanks, Gerald.

  4. Publishink
    Member
    Posted 2 years ago #

    Sorry, Gerald. Just tried this, but it returns the wp shortlink, not the goo.gl shortlink I'm generating using this plugin.

    Nor does it display the actual link, rather it returns the default wording 'This is the shortlink'. I know how to change that wording, but I'm looking for a way to display the Google shortlink elsewhere than at the foot of a post.

    The bit.ly linker plugin handles this well, and all is explained, but obviously it doesn't do Google.

    The method you suggest also results in two shortlinks, the one generated by the plugin, which is still at the foot of the post, and the one generated by your suggestion, which is added to my metadata.

  5. Publishink
    Member
    Posted 2 years ago #

    Worked it out. The result I'm looking for is achieved using the following code to display the Google short url generated by the plugin:

    <?php echo wp_get_shortlink(); ?>

    Also, in the plugin settings, I should have checked 'URL shortener integration', unchecked 'Use Permalinks for short URLs, and I had 'Append URL to ... Posts' checked.

    Once I'd made these changes, I was able to add the Google short URL to my metadata.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic