Home Forums General Issues Image via custom field in custom rss feed returning url instead of image.


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…


    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:

                            <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'); ?>
  • 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.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.