I've been struggling with this for a few days and still can't figure it how. What I am trying to do is to add a custom table field into the RSS feed, so I am using Code Snippets for this matter. Below is what I have nw, but believe I have tried all possible combinations that I could find on the WP site.
function featuredtoRSS($content) {
if ( has_post_thumbnail( $post->ID ) && get_post_type() == 'product'){
global $wpdb;
$price = $wpdb->get_row($wpdb->prepare("SELECT salePrice FROM ' . $wpdb->gm_ads_products . ' WHERE post_id = ' . $post->ID . '")); // this seems to be the issue
// $permalink_encoded = urlencode(get_post_permalink( $post->ID ));
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div><br/>☆☆☆☆☆ ' . wp_trim_words( get_the_title(), 10) . '<br/>' . $price . '<br/>' . wp_trim_words( get_the_content(), 55) . '<br/><a href="' . get_post_permalink( $post->ID ) . '"><button style="max-width:90% !important;display:block;position:relative;margin:0 auto;border: none; background: url(//4.bp.blogspot.com/-2EO8_Ohre5o/WlxIkEZmQfI/AAAAAAAAjQI/J6vLPjS2qxULn9W-NG9czoA2gfPspeS7gCLcBGAs/s320/get-it-now.jpg) no-repeat center left; padding: auto auto; border-radius:20px;width:320px;height:72px;cursor:pointer;"></button></a>' . $price;
}
return $content;
}
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');
Any ideas? As you have already guessed, it is a shopping site. Not Woo. Everything works as it should in the code above, except for the $price, that does not show in the feed. The field I'd like to be displayed in the feed is salePrice, from the gm_ads_products table. It does display the result when executing a mysql query such as SELECT salePrice FROM gm_ads_products WHERE post_id = 244