get_feed_meta

The get_feed_meta() template tag allows your templates to access data about the feed that a post was syndicated from. This can include both Custom Feed Settings that you set manually, or data that FeedWordPress automatically records about the feeds that it syndicates. This can be used to implement common aggregator features such as displaying a different “face” image or logo for each feed.

Sample

 <?php
 if (is_syndicated()) :
      $face = get_feed_meta('face');
      if (!is_null($face)) :
           ?><img src="<?php print $face; ?>"
           alt="<?php the_syndication_source(); ?>"
           /><?php
      endif;
 endif;
 ?>

This code snippet, when used in the WordPress post loop, will check whether or not each post is syndicated. If it is, it will check whether or not the feed that the post was originally syndicated from has a Custom Feed Setting defined with the name “face.” If so, it will get the value from that setting and treat it as the URL for an image to be displayed.

With this code in place, you can then define face images for each of your feeds by adding a Custom Feed Setting for each feed with the name “face” and the URL of the image as the value.

Declaration

function get_feed_meta ($key, $id = NULL)

Parameters

$key should contain a string naming the setting that you want to retrieve. Some names are reserved by FeedWordPress for automatically-stored data; all other names are available for users to provide for Custom Feed Settings.

$id is an OPTIONAL parameter. If specified, it should contain the numerical ID of a post. get_feed_meta() will return the requested Custom Feed Setting from the feed that that post was syndicated from. If $id is not specified, get_feed_meta() will use the feed that the current post was syndicated from.

Return value

Returns the value of the feed setting named in $key. This is usually a string, but for some automatically-generated feed settings (such as cats) it may be an array. If the feed has no setting by that name, returns NULL.

This page is a Wiki! Log in or register an account to edit.

Leave a Reply

Your email address will not be published. Required fields are marked *