Digital experiences for all disciplines
New Landing › How can we help? › Cardinal › SwiftPage Builder Posts in RSS Feed
New Landing › How can we help? › Cardinal › SwiftPage Builder Posts in RSS Feed
- This topic has 6 replies, 3 voices, and was last updated 9 years by David Martin – Support.
-
Posted in: Cardinal
-
July 2, 2015 at 1:45 am #190839
Hi Guys,
We’ve started putting together some Swiftpage builder posts which look great but the issue is that they aren’t displaying in our RSS feeds properly largely due to the excerpt I believe. The RSS feed is used to power our newsletter so it remains important to get this sorted for us.
I have been including the Excerpt in the the Post Meta section and while this flows to the homepage it doesn’t seem to flow to the excerpt that is used for the RSS feed.
An example of such a post is here: http://manofmany.com/fashion/10-more-top-australian-mens-fashion-blogs/
You’ll see for our Swiftpage builder posts that the excerpt is missing from this RSS feed: http://feeds.feedburner.com/ManOfMany
The posts also look a bit off in the full content feed as it maintains all formatting: http://feeds.feedburner.com/manofmanyfull
Thanks for your help in advance.
Kind regards,
ScottJuly 2, 2015 at 2:56 am #190844Hi Guys,
In looking into this further it appears the description or summary of the RSS feed items isn’t displaying properly for the Swiftpage builder posts.
I’m pulling this in using the following in the full content RSS feed.
<description><![CDATA[<?php remove_filter('the_excerpt_rss', 'insertThumbnailRSS'); 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 if(get_the_post_thumbnail()): ?> <media:content url="<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>" medium="image" width="600px" height="400px" max-width="600px" max-height="400px"/> <?php endif; ?> <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss> <slash:comments><?php echo get_comments_number(); ?></slash:comments> <?php rss_enclosure(); ?> <?php do_action('rss2_item'); ?> </item>
And this is the function I’ve used in the Functions file:
/************* Get the image *****************/ function insertThumbnailRSS($content) { global $post; if ( has_post_thumbnail( $post->ID ) ){ $content = '<p><a href="' . get_permalink( $post_id ) . '">' . get_the_post_thumbnail( $post->ID, 'thumb-image', array( 'style' =>'float:left; margin:0 15px 15px 0; padding:0; border:1px solid #000000; width: 300px; height: auto;') ) . '</a></p>' . $content . '<p><br>Visit <a href="' . get_permalink( $post_id ) . '">Man of Many</a> for the full post.</p>'; } return $content; } add_filter('the_excerpt_rss', 'insertThumbnailRSS');
I note that it won’t pull in the $content for the RSS feed if it’s a swiftpage builder post. Under WP settings > Reading > For each article in a feed, show > I’ve selected Summary.
Clearly the summary isn’t working for the swiftpage builder posts. Anyway to get this working or fix my code?
July 2, 2015 at 5:57 pm #191206Hi,
Since when using the page builder instead of normal content, you have the shortcodes format with the content inside, so we had to discard it in the feed and created a custom excerpt field that will add the desired content description to the feed.
https://www.dropbox.com/s/tmn1suozkrjrppd/Screenshot%202015-07-02%2017.56.34.png?dl=0
Give it a try in a couple posts.
-Rui
July 3, 2015 at 12:02 am #191292Hi Rui,
Thanks for replying to me.
I have already been using the Custom Excerpt in the Post Meta section for these posts. The issue is that I use a Custom format for my RSS feeds as per the coding I’ve included above and it is obviously not pulling in the Custom Excerpt we input in the Post Meta Section as you suggested.
It appears that the call to “the_content_feed(‘rss2’)” or “the_excerpt_rss” doesn’t pull in this custom excerpt properly. It will work for standard posts. In reference to the code I use above, could you please let me know how to pull this into the feed?
Kind regards,
ScottJuly 3, 2015 at 8:54 am #191393Hey,
The custom excerpt data is stored in the custom field named:
sf_custom_excerpt
Using this, you could likely use the get_post_meta function and pass this into your RSS function above.
https://codex.wordpress.org/Function_Reference/get_post_meta
Thanks,
DavidAugust 4, 2015 at 2:00 am #200388Hi David,
Thanks for much for your help. As an inexperienced coder, i’ve tried implementing your suggestion but there seems to still be something wrong with this code. It would be greatly appreciated if you’re able to help fix the issue:
add_action('init', 'customRSS'); function customRSS(){ add_feed('fullcontentfeed', 'customRSSFunc'); } function customRSSFunc(){ get_template_part('rss', 'fullcontentfeed'); } /************* Get the image *****************/ function insertThumbnailRSS($content) { global $post; $pb_status = get_post_meta($post->ID, '_spb_js_status', true); if ($pb_status) { $content = '<p><a href="' . get_permalink( $post_id ) . '">' . get_the_post_thumbnail( $post->ID, 'thumb-image', array( 'style' =>'float:left; margin:0 15px 15px 0; padding:0; border:1px solid #000000; width: 300px; height: auto;') ) . '</a></p>' . get_post_meta( $post->ID, 'sf_custom_excerpt', true ) . '<p><br>Visit <a href="' . get_permalink( $post_id ) . '">Man of Many</a> for the full post.</p>'; } else { if ( has_post_thumbnail( $post->ID ) ){ $content = '<p><a href="' . get_permalink( $post_id ) . '">' . get_the_post_thumbnail( $post->ID, 'thumb-image', array( 'style' =>'float:left; margin:0 15px 15px 0; padding:0; border:1px solid #000000; width: 300px; height: auto;') ) . '</a></p>' . $content . '<p><br>Visit <a href="' . get_permalink( $post_id ) . '">Man of Many</a> for the full post.</p>'; } return $content; } add_filter('the_excerpt_rss', 'insertThumbnailRSS');
August 4, 2015 at 10:56 am #200556Hi,
What are you trying to achieve with the above? Add a post image to the RSS feed?
The ability to add images to the RSS feed is included with the theme as standard:
/* FEATURED IMAGE IN RSS FEED ================================================== */ if ( ! function_exists( 'sf_featured_image_rss' ) ) { function sf_featured_image_rss( $content ) { global $post; if ( is_feed() ) { if ( has_post_thumbnail( $post->ID ) ) { $output = get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'float:right; margin:0 0 10px 10px;' ) ); $content = $output . $content; } } return $content; } add_filter( 'the_content', 'sf_featured_image_rss' ); }
– If you could add more details that would be great, we cannot provide full customisations so depending on how advanced this is you may need to enlist a 3rd party developer to assist you.
Thanks.
-
Posted in: Cardinal
You must be logged in to reply to this topic.