iii
August 10, 2012, 3:16am
1
I’m trying to add a link to the bottom of my wordpress RSS Feed but my getCustomField(‘Affiliate Link’) function is echoing the value instead of returning it… how do I get it to return instead?
function modRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'full', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
}
$content = $content . '<a href="' . getCustomField('Affiliate Link') . '">Peek</a>';
return $content;
}
add_filter('the_excerpt_rss', 'modRSS');
add_filter('the_content_feed', 'modRSS');
See if it is possible to add default parameter in your function getCustomField(‘Affiliate Link’) like
function getCustomField($mylink, $return = false){
// do your stuff here
if($return)
return $yourValue;
else
echo $yourValue;
}
and then call your function like getCustomField(‘Affiliate Link’, true)
Hope this helps
iii
August 10, 2012, 2:59pm
3
barbara1712:
See if it is possible to add default parameter in your function getCustomField(‘Affiliate Link’) like
function getCustomField($mylink, $return = false){
// do your stuff here
if($return)
return $yourValue;
else
echo $yourValue;
}
and then call your function like getCustomField(‘Affiliate Link’, true)
Hope this helps
Thanks for the reply! I don’t know php too well, just trying to fix this one thing but what would I place where it says “yourValue”?
Can you provide the getCustomField function you have so we can see it? Otherwise we are just guessing as to what the function looks like.