A A A
Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 4 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Including Product Image in Feed
April 20, 2008
6:04 am
Avatar
Admin
Forum Posts: 5862
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

To included the main product image (pli) in the feed, copy the following code, save it as custom-fields-for-feeds.php, and upload it to your /wp-content/plugins directory. Once it is activated, make sure under your Wordpress Dashaboard Setting's panel > Reading your feed is set to Full Content, not summary. Should work from there.

<?php
/*
Plugin Name: Custom Fields for Feeds
Plugin URI: http://justintadlock.com/archi.....ess-plugin
Description: This puts images or videos into your feeds through the use of custom fields. You can alter the custom field Keys and what is displayed.
Author: Justin Tadlock
Version: 1.0 Beta
Author URI: http://justintadlock.com
License: GPL
*/

/* Copyright 2007 Justin Tadlock (email : justin@justintadlock.com)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/* Use this shortened file to tinker with (it only displays a thumbnail). See what you can put together. Let me know if you find anything interesting or want to help developing this plugin into something better. */

add_filter('the_content', 'custom_fields_for_feeds');
add_filter('the_meta','custom_files_for_feed');

function custom_fields_for_feeds( $content ) {

global $post, $id;
$blog_key = substr( md5( get_bloginfo('url') ), 0, 16 );
if ( ! is_feed() ) return $content;

// Get the custom fields ***

// Checks for thumbnail
$pli = get_post_meta($post->ID, 'pli', $single = true);
// Checks for thumbnail alt text
$image_alt = get_post_meta($post->ID, 'Thumbnail Alt', $single = true);

// If there's no "Image Alt," "Feature Image Alt," or "Thumbnail Alt"
if($image_alt == '') { $image_alt = 'This image has no alt text'; }

// Displaying the content ***

// If there's an image, display the image with the content
if($pli !== '') {
$content = '<p>
<img src="'.$pli.'" alt="'.$image_alt.'" />
</p>' . $content;
return $content;
} // End if image

// If there's not an image or video, display the content
else {
$content = $content;
return $content;
}
} // End function
?>

Forum Timezone: UTC 0

Most Users Ever Online: 213

Currently Online:
3 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

icy1: 2636

wreed06: 175

laurie390: 169

boutiqueelliette: 156

StitchTek Services, LLC: 144

yiorgos: 127

Member Stats:

Guest Posters: 457

Members: 2471

Moderators: 1

Admins: 1

Forum Stats:

Groups: 1

Forums: 4

Topics: 4078

Posts: 18978

Newest Members: teddy1, raycrean, tseibt55, aceman, peteryoung320@gmail.com, JdsCentral

Moderators: Market Admin: 5862

Administrators: Market Admin: 5862

Market takes ecommerce to the next level with an easy to use, quick setup platform. Learn more or take the tour.