Jump to content

How do I link back to the main story from a custom picture attachment?


Celebslam

Recommended Posts

Example Picture: http://www.celebslam.com/hillary-duff-had-it-coming/hilary-duff-stalked-by-russian-maksim-miakovsky/

From this post:
http://www.celebslam.com/hillary-duff-had-it-coming/

As you can tell, there's no way to tell the picture came from an original story (unless you look at the URL but not everyone is that savvy). How do I provide a link back to the original story from the image page (I'm using an attachment.php on wordpress)?
You could take the url using $_SERVER['PHP_SELF'] or $_SERVER['REQUEST_URI'] and split off the last folder-type section: (untested code)

[code]
<?php
$link=preg_replace("#(http://(www.)?([^\.]*)\.[a-z]{2,4}/([^/]*)/)(.*)/#Ui", "\\1", $_SERVER['REQUEST_URI']);
?>
[/code]

Monkeymatt

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.