WordPress.org

Ready to get started?Download WordPress

Forums

Bitly URL - I'm trying to return author.php link to be shortened (1 post)

  1. j66brad
    Member
    Posted 1 year ago #

    Bitly is returning the first post on the author.php archieve page rather than the author permalink

    Trying to shorten
    yoursite.com/author/NAME/

    _________________________________
    In the functions file

    FUNTIONS.PHP
    backticks
    <?php
    /////////////////////////////////////////////////////////////////////////////////////////////////
    //
    // THIS code adds bitly functionality
    //
    // http://www.doitwithwp.com/create-bit-ly-short-urls-for-use-anywhere-in-your-theme///
    //
    ////////////////////////////////////////////////////
    ////////////////////////////////////////////////////
    //
    function getBitly($url) {
    $bitly = file_get_contents("http://api.bit.ly/v3/shorten?login=YOUR_USERNAME&apiKey=YOUR_APIKEY&longUrl=$url%2F&format=txt");
    return $bitly;
    } ?>
    <?php
    `backticks'

    ___________________________

    Now I've placed this code in author template file after the loop

    AUTHOR.PHP
    backticks
    <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php ?><h2>TEST 3 - try to set variable </h2></a>

    <p><a href="<?php $bitly = getBitly(get_page_link()); echo $bitly ?>"><?php $bitly = getBitly(get_page_link()); echo $bitly ?></a></p>
    backticks

    ________________________________

    Possibly Ideas was to try to hold get_author_posts_url in a variable, then pass to bitly function. Any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic