• RSS |
  • Register |
  • Log in
  • Truncating RSS titles for the fetch_rss() option of MagpieRSS turned out to be trickier than I initially expected. If you aren’t a hardcore php programmer and you’re just trying to fancy up your Wordpress blog, it can be a little obtuse as to how to achieve this. After a few Google searches turned up nothing I came up with this solution…

    <h3>Title of Your RSS Feed</h3>
    <?php
    // assign the feed to a variable named 'feed'
    $feed = 'http://url-of-your-rss-feed.com/feed/';
    	if ($feed) {
    		include_once(ABSPATH . WPINC . '/rss.php');
    // define that 'feed' is also your url
    $url = $feed;
    $rss = fetch_rss($feed);
    // string to return if feed fails
     	if ($rss == false){
    $string .= "[No Feed To Retrieve]“;
    	return $string;
    }
    $maxitems = 10;
    $items = array_slice($rss->items, 0, $maxitems);
    	foreach ( $items as $item ) :
    // define the string which is ‘$title’
    // define the action ’substr’ means sub-string or ‘part of a string’
    // define where the feed string starts - first letter is ‘0′
    // define the length of the feed string - 55 characters
    // define the trailing characters - “…”
    $title = substr($item['title'],0,55).” … “;
    ?>
    <ul>
    <li>
    // link to the rss item origin with the description as the title
    <a href=’<?php echo $item['link']; ?>’ title=’<?php echo $item['description']; ?>’>
    // print the truncated RSS title
    <?php print $title; ?>
    </a></li>
    </ul>
    <?php endforeach;
    }
    ?>
    <br /><br />
    

    This code will allow you to truncate and print the titles of an rss feed. No more worries about whether or not that aggregated feed from Twitter or another blog will break your design.

    Posted in code, hack ~

    Inspiration Round Up

    { April 9th, 2008 }

    Here’s a list of a few sites that have inspired me this week:

    1. Carsonified.com
    Designers or Event Planners? Who knows but everything they touch looks great.

    2. Causeaffect.aigasf.org
    Activism plus design, who can ask for anything more?

    3. Photoshoplady.com
    Women tutorial too.

    4. Carbonmade.com
    Well designed, great prices, looks fantastic.

    5. PSDtuts.com
    Another great looking tutorial site.

    Posted in code, hack, php ~

    (c) 2008 Jonathan Gosier 40 queries. 0.906 seconds.