WordPress: How to feed RSS with contents from another table (not wp_posts)

No GoodNeed ImprovementOKGoodExcellent (No Ratings Yet)
Loading ... Loading ...

If you want to make RSS to use data from another table, you need to edit the_excerpt_rss() function in wp-includes/feed.php file, change

$output = get_the_excerpt(true);

to something like this:

function the_excerpt_rss() {
// $output = get_the_excerpt(true);
global $wpdb, $post;
$postID = $post->ID;
$grants = $wpdb->get_results(”select abstract
from grants where post_id= $postID”);
$output=”";
foreach ($grants as $grant)
{
$output=$grant->abstract;
}

echo apply_filters('the_excerpt_rss', $output);
}

Or (the best way), write your own function like this:

function the_abstract_rss() {
global $wpdb, $post;
$postID = $post->ID;
$grants = $wpdb->get_results(”select abstract
from grants where post_id= $postID”);
$abs=”";
foreach ($grants as $grant)
{
$abs=$grant->abstract;
}
echo $abs;
}

then apply filter:

add_filter('the_excerpt_rss','the_abstract_rss');

Popularity: 1%

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word