• Hello everyone!

    I want to fetch the RSS feed of one of my websites to another using WP RSS Aggregator. This works fine, except for the video links.

    On the source website, I choose “Video” as the post format and copy the Youtube-Link to the “oEmbed URL” field in the OceanWP settings of the post, but this link will not be passed to the RSS feed.

    I guess it just needs a simple code for the Functions.php to make this possible. I found something in the internet, but unfortunately it is not helpful, because the link will simply be displayed as content in the feed, but I can’t map it as a custom field in the “WP RSS Agreggator” Plugin like that.

    That’s the code I tried:

    function wpb_rsstutorial_customfield($content) {
    global $wp_query;
    $postid = $wp_query->post->ID;
    $custom_metadata = get_post_meta($postid, 'ocean_post_oembed', true);
    if(is_feed()) {
    if($custom_metadata !== '') {
    // Display custom field data below content
    $content = $content."<br /><br /><div>".$custom_metadata."</div>";
    }
    else {
    $content = $content;
    }
    }
    return $content;
    }
    add_filter('the_excerpt_rss','wpb_rsstutorial_customfield');
    add_filter('the_content', 'wpb_rsstutorial_customfield');

    As I found out, the custom field name where the oembed link is stored is named “ocean_post_oembed”.

    Could you help me out with that? I attached a Screenshot of the field so that you know, which one I mean.

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @naou,

    Please follow the link provided to map the custom field:
    https://kb.wprssaggregator.com/article/311-how-to-set-up-feed-to-posts-custom-field-mapping.

    Also, perhaps the following code could be helpful in this situation:

    function wpb_rsstutorial_customfield( $content ) {
        if(is_feed()) {
            $post_id = get_the_ID();
            $output  = '';
    
            $custom_metadata = get_post_meta($post_id, 'ocean_post_oembed', true);
    
                if( ! empty( $custom_metadata ) ):
                    $output .= '<div>';
                    $output .= $custom_metadata;
                    $output .= '</div>';
                endif;
    
            $content = $content . $output;
        }
        return $content;
    }
    add_filter('the_content','wpb_rsstutorial_customfield');

    I hope it helps.
    Best Regards

    Thread Starter naou

    (@naou)

    Hi @skalanter

    Thanks for the fast response. ??

    I tried your code. The youtube link is passed to the feed, but I don’t think I can map it like this. In the tutorial you sent, the custom fields are in their own brackets as in the example <yt:channelId>. For me, the link is now simply in a <div> element within the content, see screenshot:

    You know what I mean? Maybe we can somehow pass the custom field with the youtube link in his own brackets <yt:link> </yt:link>. If I read it right, I can map namespace and custom fields in RSS Aggregator afterwards.

    Thanks

    Hello @naou,

    You can modify this part of the previous code:

    if( ! empty( $custom_metadata ) ):
         $output .= '<div>';
         $output .= $custom_metadata;
         $output .= '</div>';
    endif;

    Best Regards

    Thread Starter naou

    (@naou)

    Hi @skalanter

    I edited it like this:

    if( ! empty( $custom_metadata ) ):
                    $output .= '<yt:link>';
                    $output .= $custom_metadata;
                    $output .= '</yt:link>';
                endif;

    It works but it’s still somewhere between the other content:

    The WP RSS Aggregator documentation says the following:

    Do you know how we have to adapt the code to make it work?

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Modify RSS Feed with Video URL’ is closed to new replies.