Connect with us

Tips & Tricks

How to: Display RSS feeds from anywhere

Published

on

Here is a simple way to display any RSS feed in your WordPress blog.

<?php include_once(ABSPATH . WPINC . '/rss.php');
	$rss = fetch_rss('http://feeds2.feedburner.com/WPCult');
	$items = array_slice($rss->items, 0, 4);

		if (empty($items)) echo '<li>No items</li>';
		else
			foreach ( $items as $item ) : ?>
            <a style="font-size: 14px;" href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'><?php echo $item['title']; ?></a><br /> 
            <p style="font-size: 10px; color: #aaa;"><?php echo date('F, j Y',strtotime($item['pubdate'])); ?></p>
            <p><?php echo substr($item['summary'],0,strpos($item['summary'], "This is a post from")); ?></p>
            <?php endforeach; ?>

The first step is to include the WordPress file rss.php then will apply code after to style the feeds.

Of coarse I forgot to mention, change the RSS feed to the feed you want to pull.

Continue Reading
5 Comments

5 Comments

  1. Septian

    March 24, 2009 at 12:56 am

    Wow, actually I want to ask you how to do that…but, you already answer it with this post 🙂
    anyway, I’ve question for you, please look at your mailbox and answer it ASAP..thx very much…

  2. Peter

    March 26, 2009 at 7:23 am

    Very cool – I had no idea this functionality was built in. I see quite a few projects where people want this type of thing built, and I had assumed you’d have to build your own parser.

    Does anybody know how long Magpie has been in wordpress? This could have saved me lots of time..

  3. Larry

    April 8, 2009 at 9:29 pm

    Thanks but I need some more direction The code you have listed- where do I put that? In the post or page? Appreciate your time

  4. Thanks, this information is usefull..

  5. Raymond Ramy

    April 14, 2009 at 7:01 pm

    ..hey.. I think the “summary” is not functioning..

    Raymond Ramy´s last blog post..Why Choose Freelance Web Designer?

You must be logged in to post a comment Login

Leave a Reply

Tips & Tricks

Remove spaces when echoing the_title

Ever wanted to print or echo the WordPress title attribute without spaces?

Published

on

This little trick can be useful for calling custom functions and printing the title with out spaces for W3C compatibility. I used this trick in a new theme called Galleria, which will be out for public download in the coming days.

Using this comes in handy for a delicious text link:

<?php $title = get_the_title(); ?>
<a href="http://del.icio.us/post?url=<?php echo $title; ?>&amp;<?php echo str_replace(" ", "%20", $title); ?>">
Bookmark This (<?php echo $title; ?>)</a>

What I am doing is calling $title = get_the_title(); and using str_replace(" ", "%20", $title); to replace empty spaces with a %20, which is used in URL encoding empty spaces.

Alternatively you can use a dash or underscore.

Thanks to Jason Boyle for his adaption.

Continue Reading

Tips & Tricks

Display the_excerpt only if there is text

Have you ever wanted to display the excerpt only if you write one? A simple couple lines of code can display the_excerpt any where you like.

Published

on

In my new theme, I am using this coded trick to display the excerpt on a single post only if I’ve got text inside. Usually if you use the_excerpt and you don’t have one, it will fake one for you.

This is not something that I wanted to do on the single post page. So I used the following code to check if the excerpt existed.

if ( !empty( $post->post_excerpt ) ) :

Once this action is taken into account, you can factor in what code you want to out put if the post_excerpt isn’t empty.

if ( !empty( $post->post_excerpt ) ) :
	the_excerpt();
else :
	false;
endif;

The above code checks if there is an excerpt and print’s it to the screen. If there isn’t an except, it doesn’t do anything.

Continue Reading

Tips & Tricks

Add a shortcode

Published

on

This is a simple one.

/**
 * Your Blog title
 *
 */
function my_blog_title() {
	$blogname = get_bloginfo('name');
    return '<span class="blog-title">' . $blogname . '</span>';
}		  	
add_shortcode('blog-title', 'my_blog_title');

Just add this to your functions.php file and then add [blog-title] in any post or page and it will return your Blog Title. :)

Continue Reading

Random Search Terms

Title

Recent Posts: Fully Net Worth . com

Mike Bibby Net Worth.

Mike Bibby Net Worth.

Mike Bibby Net Worth. Among the world-famous basketball players, Mike Bibby is undeniably one of the top players. He is, at present, a global personality. Mike Bibby is a national champion of the year 1997 and a Pac 10 1998 player in Arizona. He is one of the most highly regarded players of the National […]

Chelsea Houska Net Worth: How Rich is the ‘Teen Mom’ Star?

Chelsea Houska Net Worth: How Rich is the ‘Teen Mom’ Star?

Chelsea Anne Houskais an American television personality who is best known for being a part of the reality television show “Teen Moms 2.” Before this, she had been a part of the show called 16 and Pregnant. As of 2019, Chelsea Houska net worth is estimated to be $80,000. Houska was born on August 29, […]

Tall Guy Car Reviews Net Worth: How Rich is the YouTube Star?

Tall Guy Car Reviews Net Worth: How Rich is the YouTube Star?

Tall Guy Car Reviews Net Worth and Bio: Corey Barrett is an American YouTube personality from Minneapolis, MN who runs the famous channel ‘Tall Guy Car Reviews’. He basically publishes video content related to car reviews and sometimes about his personal life. As of 2019, Tall Guy Car Reviews’ net worth is estimated to be […]

Danny Towers Net Worth: How Rich is the Puerto Rican Rapper?

Danny Towers Net Worth: How Rich is the Puerto Rican Rapper?

Danny Towers is an upcoming rapper who is best known for his songs “‘Motel Hell”, “Geekin”, and “Trauma”. He is currently on tour with Ski Mask The Slump God and was a good friend to late XXXTentacion. As of 2019, Danny Towers net worth is estimated to be $300,000. Danny was born on April 17, […]

Trending