Results 1 to 8 of 8
Thread: wordpress - add custom field images to rss feed
-
wordpress - add custom field images to rss feed
26 Feb 2010 @ 11.00 Hi,
I am using some custom fields in a wordpress installation for images and I would like these added to my RSS2 feed.
I have tried things like Justin Tadlocks plugin, but they still don't appear.
Custom Fields For Feeds: WordPress Plugin
The second part to my query would be to process this feed and only show the images.
Any help appreciated.
-
26 Feb 2010 @ 11.25 should be relatively simple as long as the plugin works and is compatible with anything you currently have..
have you created the custom fields ?.. with the proper values etc, they are case sensitive.
seems simple, but that's the first thing I would check ( obviously after checking the plugin is activated lol )
-
26 Feb 2010 @ 11.30 yeah, it's all active and the plugin is calling in the same value as the custom field.
PHP Code:<?php
/*
Plugin Name: Custom Fields for Feeds
Plugin URI: http://justintadlock.com/archives/2008/01/27/custom-fields-for-feeds-wordpress-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.1 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
*/
/*
Modified by Stewart Griffiths of WelshStew to specifically show images.
*/
add_filter('the_content', 'custom_fields_for_feeds');
function custom_fields_for_feeds( $content ) {
global $post, $id;
$blog_key = substr( md5( get_bloginfo('url') ), 0, 16 );
if ( ! is_feed() ) return $content;
// Place your own four custom fields by replacing the capital text
$image = get_post_meta($post->ID, 'thumbnail', $single = true);
// If there's an image, display the image with the content
// Feel free to change the styling of the image border
if($image !== '') {
$content = '<p style="float:right; padding:1px; border:1px #dddddd solid; margin-left:15px; width:125px; height:125px;">
<img src="'.$image.'" alt="Logo Inspiration" width="125" height="125" />
</p>' . $content;
return $content;
} // End if image
// If there's not an image, just display the content
else {
$content = $content;
return $content;
}
} // End function
?>
-
26 Feb 2010 @ 12.47 could you post the original so I can compare them ?
-
26 Feb 2010 @ 13.30 here you go:
PHP Code:<?php
/*
Plugin Name: Custom Fields for Feeds
Plugin URI: http://justintadlock.com/archives/2008/01/27/custom-fields-for-feeds-wordpress-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.1 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
*/
add_filter('the_content', 'custom_fields_for_feeds');
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 to see if there's an image
$image = get_post_meta($post->ID, 'Image', $single = true);
$image_alt = get_post_meta($post->ID, 'Image Alt', $single = true);
// If there's a Feature Full
if($image == '') {
$image = get_post_meta($post->ID, 'Feature Full', $single = true);
$image_alt = get_post_meta($post->ID, 'Feature Full Alt', $single = true);
}
// If there's a Feature Image
if($image == '') {
$image = get_post_meta($post->ID, 'Feature Image', $single = true);
$image_alt = get_post_meta($post->ID, 'Feature Image Alt', $single = true);
}
// If there's a Thumbnail Large
if($image == '') {
$image = get_post_meta($post->ID, 'Thumbnail Large', $single = true);
$image_alt = get_post_meta($post->ID, 'Feature Large Alt', $single = true);
}
// If there's a Thumbnail
if($image == '') {
$image = get_post_meta($post->ID, 'Thumbnail', $single = true);
$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'; }
// Checks to see if there's a video (YouTube, Google Video, etc.) associated with this post
$video = get_post_meta($post->ID, 'Video', $single=true);
// Displaying the content ***
// If there's a video, display the video with the content
if($video !== '') {
$content = '<p>
<object type="application/x-shockwave-flash" data="'.$video.'" class="left" style="align: left; width: 275px; height: 230px; border: none; padding: 0; margin: 0;" id="video">
<param name="movie" value="'.$video.'" />
<param name="wmode" value="transparent" />
<param name="quality" value="best" />
<param name="bgcolor" value="#ffffff" />
<param name="FlashVars" value="playerMode=embedded" />
</object>
</p>' . $content;
return $content;
} // End if video
// If there's not a video but an image, display the image with the content
elseif($image !== '') {
$content = '<p>
<img src="'.$image.'" 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
?>
-
26 Feb 2010 @ 14.03 not saying it will work as I cant test it, but try this
if not, try this onePHP Code:<?php
/*
Plugin Name: Custom Fields for Feeds
Plugin URI: http://justintadlock.com/archives/2008/01/27/custom-fields-for-feeds-wordpress-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.1 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
*/
/*
Modified by Stewart Griffiths of WelshStew to specifically show images.
*/
add_filter('the_content', 'custom_fields_for_feeds');
function custom_fields_for_feeds( $content ) {
global $post, $id;
$blog_key = substr( md5( get_bloginfo('url') ), 0, 16 );
if ( ! is_feed() ) return $content;
// Place your own four custom fields by replacing the capital text
if($image == '') {
$image = get_post_meta($post->ID, 'thumbnail', $single = true);
}
// If there's an image, display the image with the content
// Feel free to change the styling of the image border
if($image !== '') {
$content = '<p style="float:right; padding:1px; border:1px #dddddd solid; margin-left:15px; width:125px; height:125px;">
<img src="'.$image.'" alt="Logo Inspiration" width="125" height="125" />
</p>' . $content;
return $content;
} // End if image
// If there's not an image, just display the content
else {
$content = $content;
return $content;
}
} // End function
?>
PHP Code:<?php
/*
Plugin Name: Custom Fields for Feeds
Plugin URI: http://justintadlock.com/archives/2008/01/27/custom-fields-for-feeds-wordpress-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.1 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
*/
/*
Modified by Stewart Griffiths of WelshStew to specifically show images.
*/
add_filter('the_content', 'custom_fields_for_feeds');
function custom_fields_for_feeds( $content ) {
global $post, $id;
$blog_key = substr( md5( get_bloginfo('url') ), 0, 16 );
if ( ! is_feed() ) return $content;
// Place your own four custom fields by replacing the capital text
if($image == '') {
$image = get_post_meta($post->ID, 'thumbnail', $single = true);
}
// If there's an image, display the image with the content
// Feel free to change the styling of the image border
if($image == '') {
$content = '<p style="float:right; padding:1px; border:1px #dddddd solid; margin-left:15px; width:125px; height:125px;">
<img src="'.$image.'" alt="Logo Inspiration" width="125" height="125" />
</p>' . $content;
return $content;
} // End if image
// If there's not an image, just display the content
else {
$content = $content;
return $content;
}
} // End function
?>
-
26 Feb 2010 @ 14.20 Can you highlight the changes you have made and explain them a little so that I know what is going on.
Cheers,
-
26 Feb 2010 @ 15.01 this is the first change
I am only testing, but it looks like there is a possibility you remove a condition that you may have neededPHP Code:// Place your own four custom fields by replacing the capital text
if($image == '') {
$image = get_post_meta($post->ID, 'thumbnail', $single = true);
}
and this is the secondon this one, I removed the ! just in case it was not an 'if not' .PHP Code:// If there's an image, display the image with the content
// Feel free to change the styling of the image border
if($image == '') {
Similar Threads
-
SQL joining more than one field in the same table
By stu2000 in forum General Design & Development IssuesReplies: 5Last Post: 28 May 2010, @ 14.08 -
Embedding Blog Feed
By fbmagik in forum Just Starting Out - Help Me!Replies: 7Last Post: 13 Apr 2010, @ 18.51 -
Custom wordpress theme integration
By Jacob in forum Free Reviews & ShowcaseReplies: 4Last Post: 28 Jul 2009, @ 21.42



LinkBack URL
About LinkBacks











Help needed please
Can you link to a web page showing the problem? That makes it much...