Custom RSS Feed

Posted in: Newspaper
Post count: 240

Transitioning to NP theme…and I know this doesn’t fall under typical support but I am really hoping someone out there can help me. I have a custom RSS feed in my current site I’m trying to copy over (working on a staging server – not sure if that makes a difference).

I have added a functions.php to my child theme and added this code:

// First remove all the RSS feed links from wp_head using remove_action

remove_action( ‘wp_head’,’feed_links’, 2 );

remove_action( ‘wp_head’,’feed_links_extra’, 3 );

// Then reinsert the main RSS feed by using add_action to call our function

add_action( ‘wp_head’, ‘reinsert_rss_feed’, 1 );

// This function will reinsert the main RSS feed *after* the others have been removed

function reinsert_rss_feed() {

echo ‘<link rel=”alternate” type=”application/rss+xml” title=”‘ . get_bloginfo(‘sitename’) . ‘ » RSS Feed” href=”‘ . get_bloginfo(‘rss2_url’) . ‘” />’;

}

//NEW RSS FEED function copied from previous developer

remove_all_actions( ‘do_feed_rss2’ );

add_action( ‘do_feed_rss2’, ‘acme_product_feed_rss2’, 10, 1 );

function acme_product_feed_rss2( $for_comments ) {

$rss_template = get_stylesheet_directory() . ‘/feed-rss2.php’;

if( file_exists( $rss_template ) )

load_template( $rss_template );

else

do_feed_rss2( $for_comments ); // Call default function

}

add_filter( ‘the_content_feed’, ‘my_rssfooter’ );

add_filter( ‘the_excerpt_rss’, ‘my_rssfooter’ );

//NEW RSS FEED function copied from previous developer

function my_feed_thumbnail($content) {

if (is_feed() && has_post_thumbnail()) {

return get_the_post_thumbnail( get_the_ID(), ‘thumbnail’ ) . $content;

}

return $content;

}

add_filter(‘the_content_feed’, ‘my_feed_thumbnail’);

add_filter(‘the_excerpt_rss’, ‘my_feed_thumbnail’);

//NEW RSS FEED function copied from previous developer

add_filter(‘excerpt_length’, ‘my_excerpt_length’);

function my_excerpt_length($length) {

if ( is_feed() ) {

return 1500;

} else return 0;

}

————————————————————
then, also added a standard feed-rss2.php template to my child theme

But I still can’t get it to work. The feed on the new site is the standard RSS feed, but that’s not what I want. I need my custom RSS feed.

THANK YOU in advance to anyone who may be able to help.

Post count: 23312

Hello,

Our theme uses the default system from WordPress for feeds and does not change it’s functionality, also does not have control over it. To change that you’ll need a plugin with a similar functionality. Here you can find more details which may help you regarding RSS setup: http://www.wpbeginner.com/wp-tutorials/how-to-create-custom-rss-feeds-in-wordpress/
So, if you need to display more levels in our theme and you are not aware of the steps which are needed to take in this regard, please consider hiring a freelancer/developer to help you because we cannot provide customization services at the moment, sorry! Usually, we recommend the developers from studio.envato.com

Thanks!

Post count: 240

Yes, I read your canned answer at least a dozen times on this forum. Clearly you have a lot of users with RSS questions and you think a plugin or that WP Beginner article can help. And for most people, that isn’t the case.

So I’m hoping someone can actually help me.

Transitioning to NP theme…and I know this doesn’t fall under typical support but I am really hoping someone out there can help me. I have a custom RSS feed in my current site I’m trying to copy over (working on a staging server – not sure if that makes a difference).

I have added a functions.php to my child theme and added this code:

// First remove all the RSS feed links from wp_head using remove_action

remove_action( ‘wp_head’,’feed_links’, 2 );

remove_action( ‘wp_head’,’feed_links_extra’, 3 );

// Then reinsert the main RSS feed by using add_action to call our function

add_action( ‘wp_head’, ‘reinsert_rss_feed’, 1 );

// This function will reinsert the main RSS feed *after* the others have been removed

function reinsert_rss_feed() {

echo ‘<link rel=”alternate” type=”application/rss+xml” title=”‘ . get_bloginfo(‘sitename’) . ‘ » RSS Feed” href=”‘ . get_bloginfo(‘rss2_url’) . ‘” />’;

}

//NEW RSS FEED function copied from previous developer

remove_all_actions( ‘do_feed_rss2’ );

add_action( ‘do_feed_rss2’, ‘acme_product_feed_rss2’, 10, 1 );

function acme_product_feed_rss2( $for_comments ) {

$rss_template = get_stylesheet_directory() . ‘/feed-rss2.php’;

if( file_exists( $rss_template ) )

load_template( $rss_template );

else

do_feed_rss2( $for_comments ); // Call default function

}

add_filter( ‘the_content_feed’, ‘my_rssfooter’ );

add_filter( ‘the_excerpt_rss’, ‘my_rssfooter’ );

//NEW RSS FEED function copied from previous developer

function my_feed_thumbnail($content) {

if (is_feed() && has_post_thumbnail()) {

return get_the_post_thumbnail( get_the_ID(), ‘thumbnail’ ) . $content;

}

return $content;

}

add_filter(‘the_content_feed’, ‘my_feed_thumbnail’);

add_filter(‘the_excerpt_rss’, ‘my_feed_thumbnail’);

//NEW RSS FEED function copied from previous developer

add_filter(‘excerpt_length’, ‘my_excerpt_length’);

function my_excerpt_length($length) {

if ( is_feed() ) {

return 1500;

} else return 0;

}

————————————————————
then, also added a standard feed-rss2.php template to my child theme

But I still can’t get it to work. The feed on the new site is the standard RSS feed, but that’s not what I want. I need my custom RSS feed.

THANK YOU in advance to anyone who may be able to help.

Post count: 9544

Not theme specific, so that’s why you got a “canned” answer from the staff here. They don’t always have time to fix unrelated WordPress issues or do custom programming for you, since that isn’t part of the theme — hacking WordPress is not theme related, so sometimes better done elsewhere or by Google Search.

Just as FYI, for most stuff like that — in my own experience — it often does not work with child themes, which is why I personally don’t use child themes due to the various mish-mash of redirects and over-rides.

Tip for hacking WordPress:
a) start with default WP theme; add your custom function to default theme to get it to work.
b) Then when you have it working, fold it into the commercial theme.
c) If it doesn’t work in child theme, use only the primary theme. Or, make sure you’re adding the custom function in the *right place* for it to work.

Not sure that helps.

Adding an additional custom RSS feed is very easy; “replacing” the built-in RSS feed is a bit more complex, as you’ve discovered.

Post count: 9544

Some people do this the less elegant way:
a) add common well documented functions to remove default RSS feeds from head
b) create “custom” new RSS feed such as /sitename.cde/feed=custom using common tutorials online for “new custom RSS feed” — easily tested as working due to new URL/slug/endpoint
c) hard code the RSS link in the theme header.php file; or enqueue a new function to add the custom Feed URL to header.

Post count: 240

Chris:
Thank you very much. I’ve already made use of some of your very thoughtful and helpful posts on these forums.

Since I am copying over the exact functions and rss template from prior theme, where I know it works, then the reason it’s not working now is specific to this theme. Even if my new feed were not working on this theme, then wouldn’t this code remove the feed all together?

remove_action( ‘wp_head’,’feed_links’, 2 );
remove_action( ‘wp_head’,’feed_links_extra’, 3 );

I see you even posted that code (with additional lines – which I tried as well) to remove the feeds from the header. I’ll try it on the main theme functions file and see if that works…since you’ve said it may not work on NP child theme.

Thanks.

Post count: 9544

That’s usually why I try it with default WP theme on your current location; if it doesn’t work with the default WP theme, it won’t work with TagDiv theme either, regardless of whether main or child theme. SO, it’s part of debug process, to eliminate one possible culprit.

It’s not a job, it’s an adventure.

🙂

Post count: 23312

Hello nycinsider,

As I have explained you above, the RSS is not part of our theme and it has not any options for this case. Also, you can try to implement the WP RSS according to this topic here -> https://forum.tagdiv.com/topic/feature-image-doesnt-show-in-feedburner/ because there was discussed this problem of another customer. If you are not aware of the steps which are needed to take in this regard, please consider hiring a freelancer/developer to implement it in our theme because we cannot provide customization services at the moment, sorry!

Thank you for your understanding!

Respectfully!

Viewing 8 posts - 1 through 8 (of 8 total)
The forum ‘Newspaper’ is closed to new topics and replies.