Support » Fixing WordPress » How to add RSS without using widget

  • Hello,

    I have question on adding RSS feeds to my blog. I dont wanna add feeds on sidebar but on the footer of blog and I dont wanna use RSS widget but parameters of this widget like php function. I need in output titles, dates and authors of feed. I thought it could be this function wp_widget_rss_output but dont know how to use it. Thanks for help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • bump.

    I’m also looking for something similar. I got a local news feed I would like to add to a ‘page’ and I don’t want to use the widget… because that puts it in the sidebar, which is want i don’t want.

    perhaps a plugin? I’ve looked to no avail

    I’m not fully sure if this will answer your question (I’m relatively new to wordpress hacking), but I use the following code in a custom made template for a page:

    <div class="...">
        <h2>News headlines</h2>
        <!-- the feed should only use category=3 -->
        <p class="..."><a href="feed:<?php bloginfo('url'); ?>/wp-rss2.php?cat=3">RSS FEED</a>
        <ul class="...">
    	 <!-- Only show category=3 here with a max of 5 posts -->
        	 <?php $recent = new WP_Query("cat=3&showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
    	     <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    	    	    Posted by <?php the_author() ?> on <?php the_time('D, jS F, Y') ?>
    	 <?php endwhile; ?>

    It does a number of things:
    1) Put a title for the block (in [h2])
    2) Under the title there is a link to the RSS feed for customers to click on in case they want to subscribe to this feed. The feed includes only posts that belong to a certain category (?cat=3).
    3) Within the [ul] block there is a loop that retrieves a maximum of 5 posts that belong to a specific category.

    That’s it. It might not be the “wordpress way” but it works. If you want ALL posts, just remove the “cat=3” parameter (twice). Likewise, you can retrieve more posts by changing “showposts=5”. I had to use trial and error to get the right category number because I couldn’t find that in the admin interface. Could be my shortsightedness.

    I hope this helps.

    Now, I have a related question of my own: when users click on the feed link, the title of the feed (NOT the title of the posts) in the RSS reader is set to the title of my blog. I would like to be able to change this title, more specifically add the category in this case. Any idea how I can do this?

    <!-- RSS feed as a page by r11 -->
    				if (is_page('RSS Syndication') ){
    					require_once(ABSPATH . WPINC . '/rss.php');
    						$rss = fetch_rss('');
    						for( $i=0; $i<25; $i++ ) {
    							$pubdate=substr($item['pubdate'], 0, 16);
    							echo '
    <a href="'.$item['link'].'" title=" '.$item['title'].'"><b>'.$item['title'].'</b></a>
    '.$item['content'].' content
    '.$item['summary'].' summary
    '.$item['title'].' title
    '.$item['content'].' content
    <a href="'.$item['link'].'">more...</a>
    <!-- End of feed -->

    I am not sure why but not all of the information gets parsed. Maybe someone could help me. Anyway, if you put this into the page.php file of your template, as long as “is_page(???)” is set to the page ??? (name of your page), then it will run the parser. I hope this helps, now we can go and figure out how to get more information from the feed to display.

    Working version:

    <?php require_once(ABSPATH . WPINC . '/rss.php'); wp_widget_rss_output('', array('items' => 5, 'show_author' => 1, 'show_date' => 1));

    How about showing the rss summary or exerpt. Is that possible?


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to add RSS without using widget’ is closed to new replies.