0

I am a totally fresh with wordpress I have this website : http://www.raminusa.com/ in footer there is a column name "Popular Link" and I want to replace it with Recent News that I will do but below this heading I need my first 5 or 4 recent post from my wordpress blog.

My wordpress blog is : http://immigrationstatus.wordpress.com

I do not know how is it possible can some one help me with this.

Here is the code I used:

<?php 
    $url = "http://immigrationstatus.wordpress.com/rss2/";
    require_once(ABSPATH . WPINC . '/rss-functions.php');
    $rss = fetch_rss($url);
?>
<ul class="footer-links">
    <?php
        foreach ($rss->items as $item ) {
            echo "<li><a href='".$item['link']."' title='".$item['title']".'>".$item['title']."</a></li>";
        }
    ?>
</ul>

1 Answer 1

0

EDIT After a brief chat with Original Poster, the following solution works:

  • Install the Magpie RSS library.

  • Create a folder in the root directory of raminusa.com, name it magpierss

  • Upload 4 files (*rss_fetch.inc*, *rss_parser.inc*, *rss_cache.inc*, and *rss_utils.inc*), and the directory extlib to this new folder

In the footer script of raminusa.com (which should be in the same directory as the newly created magpierss folder), add the following script.

<?php
    $url = "http://immigrationstatus.wordpress.com/feed/";
    require_once('magpierss/rss_fetch.inc');
    $rss = fetch_rss($url);
?>
<ul class="footer-links">
    <?php
                if($rss) {
                        foreach ($rss->items as $item ) {
                                $link = $item['link'];
                                $title = $item['title'];
                                echo '<li><a href="' . $link . '" title="' . $title . '">' . $title . '</a></li>';
                        }
                } else {
                        echo '<li>Sorry, RSS Feed could not be loaded</li>';
                }
    ?>
</ul>

To change the amount of links shown, go to your WordPress installation, and go to Settings > Reading. Change the value for Syndication feeds show the most recent. The default is 10 most recent posts.

9
  • Thanks Marc I applied what you said but it is giving me this error: raminusa.com/rss.php
    – KennEthel
    Commented Mar 13, 2013 at 12:04
  • Can you provide the contents of rss.php in your original post? It would help determine what exactly goes wrong on line 9. Commented Mar 13, 2013 at 12:06
  • ok wait I am giving it to you
    – KennEthel
    Commented Mar 13, 2013 at 12:10
  • I posted it check now
    – KennEthel
    Commented Mar 13, 2013 at 12:12
  • I have edited my answer. It saves the array elements in separate variables before using them in the echo line. Commented Mar 13, 2013 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.