[wp-trac] [WordPress Trac] #9963: get_permalink() returns wrong link outside The Loop
WordPress Trac
wp-trac at lists.automattic.com
Thu Jun 28 09:03:38 UTC 2012
#9963: get_permalink() returns wrong link outside The Loop
--------------------------+----------------------
Reporter: fmorel90 | Owner: ryan
Type: defect (bug) | Status: closed
Priority: high | Milestone:
Component: Permalinks | Version: 2.8
Severity: normal | Resolution: invalid
Keywords: |
--------------------------+----------------------
Changes (by johnbillion):
* status: reopened => closed
* version: 3.4 => 2.8
* resolution: => invalid
Comment:
iLobster, `get_permalink()` is not the function you should be using in
this case. What you're really asking for is a function which returns the
current URL.
I had thought there was a ticket open suggesting a `get_current_url()`
function, but it looks like I'm mistaken. The code is quite simple though:
{{{
$current_url = ( is_ssl() ? 'https://' : 'http://' ) .
$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9963#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list