0

I have a post with a tablepress table with many columns. When the post is added to RSS, Mailchimp emails it out, but the table is jumbled due to the many columns squeezed together.

I found the table appears correctly if I trim all columns but the first 2, so I'm seeking a way to get a trimmed table into the RSS feed while the full table remains visible/accessible in the post.

I've tried multiple approaches to do this and am open to other options. My latest attempt was creating a duplicate post with the trimmed table and using code to hide the duplicate post in the blog - see below. But this and other snippets using pre_get_posts keeps failing to hide the post.

function myFilter($query) {
    if ($query->is_feed) {
        $query->set('cat','-1'); //Don't forget to change the category ID
    }
return $query;
}

add_filter('pre_get_posts','myFilter');
4
  • Does the whole post have to appear in the RSS feed, or could you set it to show excerpts and let people come to youre site to read the whole thing?
    – Chris Cox
    Commented Jun 27 at 21:41
  • I need the whole post to appear in the RSS feed, all of the rows of the table.
    – somuser
    Commented Jun 28 at 12:57
  • where is this snippet located in your codebase? I notice you've mentioned Tablepress is this a standard vanilla HTML table? Or is it generated via shortcodes/custom blocks?
    – Tom J Nowell
    Commented Jul 2 at 8:04
  • I looked up tablepress and it uses a block, the table data is not contained in the post, neither is its markup, instead it uses an ID on a shortcode attribute to reference data stored elsewhere. This opens up several options of filtering the shortcode text before processing based on wether is_feed is true or false to show larger or smaller tables. Also note that $query->is_feed is not a variable, it's a function and needs () on the end
    – Tom J Nowell
    Commented Jul 2 at 8:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.