Home › Forums › General Issues › Image via custom field in custom rss feed returning url instead of image.
I realize the issue is in the “the_field(‘imagen’);” line. But every modification I have tried doesn’t even display the url…
Code:
function traveltips_postrss($content) {
global $wp_query;
$postid = $wp_query->post->ID;
$image = the_field('imagen');
$descripcion1 = "<p>".the_field(descripcion)."</p>";
return $content;
}
add_filter('the_excerpt_rss', 'traveltips_postrss');
add_filter('the_content_feed', 'traveltips_postrss');
Example of modifications:
$image = get_field('imagen');
$image = get_post_field($wp_query->post->ID, 'imagen', true);
$image = get_post_meta($wp_query->post->ID, 'imagen', true);
$image2 = '<img src="' . $image . '" />';
$image3 = "<img src=".get_field('imagen')['url']."/>";
Try
global $post;
$image = the_field('imagen', $post->ID);
It returns the url as well… Maybe the problem is not with the line but with the code in the custom rss template (maybe the excerpt strips the img tag?)
Here’s the code:
<item>
<title><?php the_title_rss();?>, <?php the_field(region); ?></title>
<link><?php the_permalink_rss(); ?></link>
<pubDate><?php the_field(fecha_de_inicio); ?></pubDate>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php if ( strlen( $post->post_content ) > 0 ) : ?>
<content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
<?php else : ?>
<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
<?php endif; ?>
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
</item>
We have problems with the values returned as well.
We’ve defined an image field and set it to return an “Image-Array”. The value that gets returned is the ID, no matter what was chosen in the field editor.
@silenthill that I don’t know. I don’t know much about rss excerpts and what happens to them.
@chrisdaswiss this is usually a sign the a pre_get_posts
filter is filtering queries it should not be.
The topic ‘Image via custom field in custom rss feed returning url instead of image.’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.