SimplePie 1.5 is now available!

SimplePie Documentation.  Learn how to use this thing.  It's way better than going to school.

You are here: Documentation » API Reference » SimplePie » get_link()

get_link()

Description

class SimplePie {
	get_link ( [int $key = 0 [, string $rel = 'alternate'] ] )
}

Returns a single array location containing a link for the feed. This is useful for when a feed associates more than one link to itself.

Availability

  • Available since SimplePie 1.0.
  • Previously existed as get_feed_link() since SimplePie Preview Release.
  • Previously existed as get_feed_permalink() since SimplePie 0.8.

Parameters

key

The item that you want to return. Remember that arrays begin with 0, not 1.

relation

The relationship of links to return.

Examples

Loop through each item and do something with each

<?php
require_once('../simplepie.inc');
 
$feed = new SimplePie('http://simplepie.org/blog/feed/');
$feed->handle_content_type();
 
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<title>Sample SimplePie Page</title>
 </head>
<body>
 
	<div class="header">
		<h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1>
		<p><?php echo $feed->get_description(); ?></p>
	</div>
 
	<?php foreach ($feed->get_items() as $item): ?>
 
		<div class="item">
			<h2 class="title"><a href="<?php echo $item->get_link(0); ?>"><?php echo $item->get_title(); ?></a></h2>
			<?php echo $item->get_description(); ?>
			<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
		</div>
 
	<?php endforeach; ?>
 
</body>
</html>

See Also


reference/simplepie/get_link.txt · Last modified: 2011/03/06 03:56 (external edit)