• Resolved Chris

    (@christof15)


    Hi, i’m using your plugin to have a feedback form on every post page.
    I’m generating a current post/pagelink with this code in functions.php:

    // START ADD CURRENT PAGE SHORTCODE IN WP
    add_shortcode ('geturl', 'get_current_page_url');
    function get_current_page_url() {
    	$pageURL = 'http';
    	if( isset($_SERVER["HTTPS"]) ) {
    		if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    	}
    	$pageURL .= "://";
    	if ($_SERVER["SERVER_PORT"] != "80") {
    		$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    	} else {
    		$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    	}
    	return $pageURL;
    }
    // END ADD CURRENT PAGE SHORTCODE IN WP

    ..and in the AF template:
    <a href="[geturl]" target="_blank" rel="noopener">[geturl]</a>
    So far so good: the postlink comes through nicely but includes 433. https://www.mywebsite.nl:433/category/post/

    I would like to make this a clean url.. Thanks!

    • This topic was modified 4 years, 8 months ago by Chris.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Chris

    (@christof15)

    Remove .":".$_SERVER["SERVER_PORT"]

    New function:

    // START ADD CURRENT PAGE SHORTCODE IN WP
    add_shortcode ('geturl', 'get_current_page_url');
    function get_current_page_url() {
    	$pageURL = 'http';
    	if( isset($_SERVER["HTTPS"]) ) {
    		if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    	}
    	$pageURL .= "://";
    	if ($_SERVER["SERVER_PORT"] != "80") {
    		$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    	} else {
    		$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    	}
    	return $pageURL;
    }
    // END ADD CURRENT PAGE SHORTCODE IN WP
    Plugin Author fabianlindfors

    (@fabianlindfors)

    Nice that you figured it out, good job! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘geturl current post/pagelink includes 433’ is closed to new replies.