Viewing 2 replies - 1 through 2 (of 2 total)
  • Mark

    (@delayedinsanity)

    You have two options depending on what you want to do, and how you’re going about doing it.

    The less likely but still available first option is to filter the_shortlink; there are four arguments passed in total, including the formatted link, the shortlink itself, the text (for the formatted link) and the title of the page the shortlink references. You could easily hook into this and return just the $shortlink (the second argument).

    The other way is to call wpbitly_get_shortlink() directly. Argument one should be the current permalink (though you can pass this as empty so long as you get argument two correct), and the second argument is the post ID you want the shortlink for. For example;

    <?php
    /* this will return the shortlink for a post/page with the ID of 12 */
    echo wpbitly_get_shortlink('', 12);
    
    /* You can also pass it the permalink in case something fails retrieving or generating the shortlink */
    $post_id = get_the_ID();
    $permalink = get_permalink($post_id);
    $shortlink = wpbitly_get_shortlink($permalink, $post_id);
    ?>
    Thread Starter alevalentini

    (@alevalentini)

    Perfect. That made the trick. Thank you! Great plugin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting just the url’ is closed to new replies.