• Resolved helices

    (@helices)


    I want to change two standard WordPress RSS feed behaviors:

    [1] I want to eliminate both “separator” and “site title” from the title of all posts in my feeds. The default is: “post title” | “site title” and I want to pass ONLY: “post title”

    [2] I want to replace the URL of my blog post with some other string, which will probably be some other URL.

    I happen to be using Twenty Fifteen theme now, if that matters

    How can I do [1] and [2]?

    How can my changes persist across updates?

    Please, advise. Thank you.

    ~Mike

Viewing 10 replies - 1 through 10 (of 10 total)
  • helices

    First of all, “post title | site title”, thats not the default title for posts in the feed, you must be using something to change it, so I’m using the priority 999 so that nothing else might filter the title and link after we’re done with that.

    Below is the code that you can put in your theme’s functions.php file, just make sure to replace the link with whatever you want it to be.

    add_filter('the_title_rss', 'my_new_rss_title',999);
    
    function my_new_rss_title($title) {
        $title = get_the_title();
        return $title;
    }
    
    add_filter('the_permalink_rss', 'my_new_rss_permalink',999);
    
    function my_new_permalink($link) {
        $link = "https://example.com";
        return $link;
    }

    I hope it helps ??

    Thread Starter helices

    (@helices)

    Hi, Gagan!

    Thank you for your response. I will try this tonight

    You say, “thats not the default title for posts in the feed”

    What is the default?

    How can I locate whatever is changing this default?

    Theme: Twenty Fifteen

    Plugins:
    BruteProtect
    WP-Activity
    WP Pipes
    WP Slimstat

    I found function get_wp_title_rss in wp-includes/feed.php, which looks to me that “post title | site title” is, indeed, the default feed title

    What am I missing?

    ~ Mike

    helices

    Always welcome ??

    The default way for the title to appear is the way you want it to be. Only post title.

    I checked the plugins and theme you said you’re using, none seem to be using the filter “the_title_rss” for modifying the title, but there are certain things WP Pipes is doing with the RSS(maybe just importing the RSS and providing an export in RSS format).

    About finding out what could be doing that, the easiest way would be by using terminal, go into the WordPress folder and write

    grep -R "the_title_rss" .

    It will give you the names of the files using that filter.

    Also, since WordPress uses the function get_the_title(); to fetch the title of the post, maybe something could be manipulating that function by using the_title filter.

    Thread Starter helices

    (@helices)

    Hi, Gagan!

    OK, I’m finally back to working on this.

    [1] I have applied your title function – we’ll see how that works.

    [2] Regarding the link, it will vary by every post in the feed. This site exists only as an RSS aggregator, like the soon-to-be defunct Yahoo Pipes. I’m collecting RSS posts from hundreds of RSS feeds, categorizing them via WP Pipes, then feeding my category RSS feeds to social media, like Facebook and Twitter. I want that link in all of my feeds to be the original source URL, not a link to my website.

    Do you have ideas I can try?

    [3] Regarding whatever is modifying my RSS feed titles, I finally got in via SSH and have been grepping in wp-includes. Now, I understand your comments about default WP feed titles.

    I’m grepping in the wrong directories, as I’ve not yet found the culprit. Any ideas which directories to search?

    Thank you

    ~Mike

    Mike

    In the above code, the function name should have been my_new_rss_permalink which I typed wrong, so it won’t work.

    Now I studied the WP Pipes plugin a bit, and I was able to make the RSS feed link to point to the original source URL by the following code:

    add_filter('the_permalink_rss', 'my_new_rss_permalink', 999);
    
    function my_new_rss_permalink($link) {
        $content = get_the_content();
        preg_match_all( '/<a href="(.+?)" target="_blank">Original Source<\/a>/i', $content, $matches );
        if(isset($matches[1])&&  is_array($matches[1])&&  count($matches[1])>0){
            $link = $matches[1][0];
        }
        return $link;
    }

    Though I was able to do that by adding “Original Source” processor while creating the Pipe and added “Original Source” in the content of the post.

    Regarding the RSS Feed titles, best place to start will be the wp-content folder where all plugins and themes reside.

    Thread Starter helices

    (@helices)

    Hi, Gagan!

    OK, I’m this permalink code a try.

    I’ll have to figure out how to do that “Original Source” thing …

    Regarding the title issue, I’ve found that I was wrong. It’s Facebook that is adding ” | WP Site Title”

    What could be a way to have my feed present “original source site title” in my RSS feed?

    Thank you for your creative help. I’m learning a lot with this

    ~ Mike

    Mike

    Here’s a screencast I’ve made on creating a Pipe with Original Source in the content. Let me know if anything needs further explanation.

    It might take a while before the 1080p resolution is available on YouTube for this video. It appears that YouTube starts by processing the lower resolutions first, then going to larger resolution.

    Mike

    Were you able to create a pipe with the Original Source as I mentioned in the Video?

    Thread Starter helices

    (@helices)

    Hi, Gagan!

    Yes, I got that to work

    But, I realize that I have little control over how Facebook chooses to display RSS posts on my pages ??

    Thank you for your help

    ~ Mike

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to configure WP RSS feed output?’ is closed to new replies.