WordPress.org

Ready to get started?Download WordPress

Forums

How to add an RSS feed to your page (10 posts)

  1. desmondo
    Member
    Posted 7 years ago #

    Hi all,

    I have been reading for a long time and I seem to be going around in circles. Can anyone give me advice or point me in the right direction?

    I have set up my wordpress content under a specific category called news. On this page I have the full postings displayed.

    On the homepage to my site, (WordPress is in a sub-folder called "content"), I would like to be able to display the list of posts in brief, then you can click to go to the news page and view all posts. On this page I would like to pull in content from 2 different categories, with different surrounding HTML code for each. Therefore, I wouldn't like to have this page sitting in the WordPress directory, as it has a different layout to the rest.

    I have been reading up on RSS, but I can't figure out how I actually pull the news content in on my homepage? I want to limit the amount of text to 50 words or so (using the <!--more--> option I think?).

    I have found my RSS feed link, how do I pull the content in?
    http://localhost/content/category/news/feed/rss/

    Thanks for your help.

  2. desmondo
    Member
    Posted 7 years ago #

    I guess the other question would be, do I need a plugin for this?

  3. tsguitar
    Member
    Posted 7 years ago #

    Wait, wait. That might be more complicated than you need. You just want to have entries from the News category displayed on your site home page, right? You lose me when you write about pulling in content from 2 other categories, though.

    Any page on your site can have content from WordPress. Just include this at the top of each page:

    <?php
    /* Short and sweet */
    require('../wp-blog-header.php');
    ?>

    Change that address to point to your copy of wp-blog-header.php and you should be set. This should help:
    http://wordpress.org/support/topic/110780?replies=6

    P.S. But if you really want to go the RSS route, I've used this piece of software and it allows you to customize the feed however you wish:
    http://lastrss.oslab.net/

  4. desmondo
    Member
    Posted 7 years ago #

    Thanks for your reply TSguitar.

    I knew I wouldn't make sense that late in the day! On my hompage, I want to pull in content from 2 different categories. So all posts from news, then all posts from Events. They would appear on different parts of the page.

    I just want to display the HTML for the latest 10 posts (for each category) on my homepage; the first 50 words of the post, then read more or something and that will take you to the page.

    Hope that makes sense. I guess the question is how do I get the HMTL onto my hompage. I don't want the header, just the last few posts. Although I see where you're coming from, perhaps I can just include a chunk of code from WordPress itself?

    Cheers
    Paul

  5. desmondo
    Member
    Posted 7 years ago #

    Just reading that post, I think I see where you're coming from and will come back if I can't get it sorted!

    Thanks again!

  6. tsguitar
    Member
    Posted 7 years ago #

    The wp-blog-header bit is just to essentially hook that page up to WordPress. After you include that piece at the top of the page, from there you can run normal WordPress functions and the content will be displayed. In other words, figure out how to display content from the appropriate categories on your main WordPress page. Once you figure that out, copy that code to your home page and just do the wp-blog-header thing at the top of the page. That should do it.

  7. desmondo
    Member
    Posted 7 years ago #

    Yep, cheers for that. Got it partially working, just trying to tweak it currently. Getting there slowly :)

    Thanks for your help.

  8. desmondo
    Member
    Posted 7 years ago #

    Hello all,

    I've almost got up and running what I need, but I'm really stuck and I desperately need some help!

    I tried using this plugin to get the content for my homepage:
    http://www.coffee2code.com/archives/2004/08/27/plugin-customizable-post-listings/

    The code within my loop is:
    <?php c2c_get_recent_posts(5, "

  9. <h2>%post_title%</h2>%post_excerpt_short%
  10. ", '2'); ?>

    The problem is that when I try to add just an excerpt, it doesn't include the image. This plugin is nearly 3 years old, so I am guessing I could do this with the latest version of wordpress without the plugin?

    Here is another block of code I had before the plugin, sitting on the homepage:

    <?php if (have_posts()) : ?>
    <ul id="graphicList">
    <?php while (have_posts()) : the_post(); ?>

  11. <h2>"><?php the_title(); ?></h2>
    <?php the_content('Read the rest of this entry »'); ?>
  12. <?php endwhile; ?>

    <?php endif; ?>

    I need to tweak it to get the following:

    - Just the posts from a single category (id=2)
    - Only an excerpt of the first 200 words, but still including any images at the start of the post.
    - I want to limit the amount to the first 10 posts irrespective of whether they are in the archives or what not.

    Please help me, I'm really struggling!

  • desmondo
    Member
    Posted 7 years ago #

    I have managed to fix a few things and I've learned about the optional excerpt. I would still like to pull in only the content for one category (id=2) and limit the amount to the first ten posts (regardless of month). Can anyone tell me how to do this with the following code?

    <?php if (have_posts()) : ?>
    <ul id="graphicList">
    <?php while (have_posts()) : the_post(); ?>

  • <h3><?php the_title(); ?></h3>
    <?php the_excerpt('Read the rest of this entry »'); ?>
  • <?php endwhile; ?>

    <?php endif; ?>

    Thanks

  • desmondo
    Member
    Posted 7 years ago #

    If anyone is interested, I think I've solved it, with a little help from this page:
    http://codex.wordpress.org/The_Loop

    My final code:

    <?php if (have_posts()) : ?>
    			  	<?php query_posts('category_name=news&showposts=0'); ?>
    				<ul id="graphicList">
    				<?php while (have_posts()) : the_post(); ?>
    					<li>
    						<h3><a href="/content/news/#newsItem<?php the_ID(); ?>"><?php the_title(); ?></a></h3>
    						<?php the_excerpt('Read the rest of this entry &raquo;'); ?>
    						<a class="arrowLink" href="/content/news/#newsItem<?php the_ID(); ?>">Read more</a>
    					</li>
    				<?php endwhile; ?>
    				</ul>
    			<?php endif; ?>

    Seems to be very quiet around the forum these days, or is it just me?!

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags