WordPress.org

Ready to get started?Download WordPress

Forums

Custom field Image and URI in RSS / feed (1 post)

  1. nubiana
    Member
    Posted 6 years ago #

    I'm using a showcase theme which uses custom fields to display post images. I'd like these images and a link to the original site to be displayed in my feed. The relevant fields are "Thumbnail Full" and "URI". The following modified plugin which I found on another support topic - http://wordpress.org/support/topic/99432?replies=5 - works, but I don't know how to edit it to make it show:

    • the thumbnail image itself instead of the link text
    • the URI as a link

    Can anyone help with this?

    <?php
    /*
    Plugin Name: Custom to Feed Content
    Plugin URI: http://wordpress.org/support/topic/63420
    Description: Append post custom fields to syndication content.
    Author: Kaf Oseo
    Version: 0.1
    Author URI: http://szub.net
    
    	Copyright (c) 2006 Kaf Oseo (http://szub.net)
    	Custom2Feed Content is released under the GNU General Public
    	License (GPL) http://www.gnu.org/licenses/gpl.txt
    
    	This is a WordPress plugin (http://wordpress.org).
    */
    
    function szub_custom2feed($text) {
    /* >> Begin user-configurable variables >> */
    
    //  $pass_keys - Array of allowed custom keys. Modify to your needs.
    	$pass_keys = array('Thumbnail Full', 'URI');
    
    /*  $list_mode - How to display your custom keys/values. Options are:
    	'ul'   : Unordered list.
    	'ol-1' : Ordered (numbered) list (also: 'ol').
    	'ol-A' : Ordered (lettered) list.
    	'dl'   : Description list.
    	'p'    : Individual paras (customkey: customvalue
    ).
    	'tag'  : Pseudo-tag format (<customkey>customvalue</customkey>).
    */
    	$list_mode = 'ul';
    
    //  $sep - custom key:value separator character(s).
    	$sep = ': ';
    
    /* << End user-configurable variables << */
    
    	$customtext = '';
    	if(is_feed()) {
    		global $post_meta_cache, $wp_query;
    
    		if ( $keys = get_post_custom_keys() ) {
         foreach($keys as $key) {
    				if( in_array($key, $pass_keys) ) {
    					foreach(get_post_custom_values($key) as $value)
    						$customtext .= szub_line_mode($key, $value, $sep, $list_mode);
    				}
    			}
    
    			if($customtext) {
    				switch($list_mode) {
    					case 'ul':
    						$text .= "\n<ul>\n$customtext</ul>";
    						break;
    					case 'ol':
    					case 'ol-1':
    						$text .= "\n<ol>\n$customtext</ol>";
    						break;
    					case 'ol-A':
    						$text .= "\n<ol type=\"A\">\n$customtext</ol>";
    						break;
    					case 'dl':
    						$text .= "\n<dl>\n$customtext</dl>";
    						break;
    					default:
    						$text .= $customtext;
    				}
    			}
    		}
    	}
    
    	return $text;
    }
    
    function szub_line_mode($key, $value, $sep, $list_mode) {
    	switch($list_mode) {
    		case 'ul':
    		case 'ol':
    		case 'ol-1':
    		case 'ol-A':
    			return "<li>$key$sep$value</li>\n";
    		case 'dl':
    			return "<dt>$key$sep</dt><dd>$value</dd>\n";
    		case 'tag':
    			return "\n<$key>$value</$key>";
    		default:
    			return "$key$sep$value
    ";
    	}
    }
    
    add_filter('the_content', 'szub_custom2feed', 9);
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic