Forums

Can we have RSS on the Search Results? (5 posts)

  1. WordpressChina
    Member
    Posted 2 years ago #

    I think it would be very cool to have RSS feeds from my blog's search results. Wordpress already has a wide range of RSS feeds: posts, comments, categories. But is there a plugin that will generate on-the-fly RSS feeds from search results?

    Tks!

  2. Kafkaesqui
    Moderator
    Posted 2 years ago #

    It already exists in WordPress. For example, here's a search result for 'wordpress' from my blog:

    http://guff.szub.net/feed/rss2/?s=wordpress

  3. WordpressChina
    Member
    Posted 2 years ago #

    Very cool! I didn't know that existed as a native feature. I can't find info on it in the codex--are there certain tags we can use to create an automatic RSS link on our search results page that can link people to that?

    Wow, I'm really amazed, and pleased :-)

  4. Kafkaesqui
    Moderator
    Posted 2 years ago #

    "...are there certain tags we can use to create an automatic RSS link on our search results page that can link people to that?"

    There is no template tag per se which does this, but we can construct one:

    <a href="<?php bloginfo('rss2_url'); echo '?s=' . stripslashes(stripslashes($s)); ?>">RSS feed for search results</a>

    For a site *not* using custom permalinks:

    <a href="<?php bloginfo('rss2_url'); echo '&amp;s=' . stripslashes(stripslashes($s)); ?>">RSS feed for search results</a>

    The bloginfo('rss2_url') portion is described here. The echo statement appends the search string ($s) to the feed's url (the nested stripslashes() are there to clean out potential PHP escape sequences from the search string).

    You can surround this with an if( is_search() ) conditional to make sure it only displays on search results (i.e. you're adding it to the sidebar). More on conditional tags here:

    http://codex.wordpress.org/Conditional_tags

  5. WordpressChina
    Member
    Posted 2 years ago #

    Beautiful. I liked Wordpress before, but now its gracefulness is becoming more apparent.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags