Tips & Tricks
How to: Display RSS feeds from anywhere
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.
Tips & Tricks
Sick of images being to large for the content area?
Have you ever uploaded an image that might have been a tad bigger than the width of your content area? I know I have! So here is a little CSS fix to handle these situations.
.post img { max-width: 600px; height: auto; }
That’s it, really simple huh. Just make sure that you change the .post
to the correct body class(which starts with a “.“) or body ID(which starts with a “#“).
Would you like a quick explanation?
The CSS is just telling any image inside the class of .post
to not be more than 600px wide. By the way make sure you change it to fit the dimension of your content width. And the height attribute is set to auto to automatically change the height to match the new width. 🙂
Tips & Tricks
Remove the title attribute using jQuery
In WordPress, when you use wp_page_menu
your anchor attribute’s usually carry a title with the same name. I’m not sure if it’s correct to do this, but it bother me when I hover over a page menu navigation link and I get a hover of the title.
So on my site I used jQuery to remove the title:
$("#nav a").removeAttr("title");
Pretty simple huh?
Tips & Tricks
How to: Open external links in a new window
Over the weekend, I attended WordCamp Denver, and I was asked by John Hawkins how to force links to open in a new tab with out editing the source code. So, today lets learn a simple jQuery trick to open all external links in your site in a new tab or window. We are going to make sure you have jQuery active on your site, you can do this easily in WordPress, since it’s bundled with the latest installations. Use this code in your header: <?php wp_enqueue_script('jquery'); ?>
then, below the wp_head
add the following:
<script type="text/javacript"> var $j = jQuery.noConflict(); $j(document).ready(function() { //external attribute $j("a:not([@href*=http://YOURSITE.com/])").not("[href^=#]") .addClass("external") .attr({ target: "_blank" }); } ); </script>
That’s it, just make sure you change the http://YOURSITE.com to your website.
Update
If you like you can remove the var $j =
and replace all $j
with simply just $
-
Tips & Tricks4 months ago
WordPress Security Hacks
-
Pages1 month ago
Write For Us – Guest Post
-
Showcase1 month ago
StylizedWeb.com
-
News4 weeks ago
How to: Show/Hide any div box with jQuery in WordPress
-
Tips & Tricks3 months ago
How to: show/hide a widget in WordPress with jQuery
-
Tips & Tricks5 days ago
Remove the title attribute using jQuery
-
Plugins3 months ago
Top Membership plugins
-
Tips & Tricks1 month ago
Limit the characters that display on the_title
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…
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..
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
Edhie Baskoro Yudhoyono Muda Cerdas Jujur Peduli Rakyat
April 12, 2009 at 4:08 pm
Thanks, this information is usefull..
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?