WordPress.org

Ready to get started?Download WordPress

Forums

Add current URL code (2 posts)

  1. finance-business.org
    Member
    Posted 3 years ago #

    I am trying to add current URL to my affiliate links to track profiles dynamically.

    Anyone know what is the PHP code for the current URL? I Just need to add the PHP without spaces at the end of the affiliate link in my sidebar.php.

    I appreciate your assistance.

  2. Ben Sutcliffe
    Member
    Posted 3 years ago #

    Place this bit of PHP anywhere above the link:

    $current_url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

    Then put this bit into your link where you want your current web address:

    <?php echo $current_url; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.